home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / utilitys / sman_1_0 / part01 next >
Encoding:
Text File  |  1991-05-18  |  63.7 KB  |  2,687 lines

  1. Path: news.larc.nasa.gov!amiga-request
  2. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v91i105: sman 1.0 - a manual type program, Part01/02
  4. Reply-To: "J. Spencer" <bhgs@utcs.utoronto.ca>
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v91i105@ab20.larc.nasa.gov>
  7. Date: 18 May 91 01:52:32 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga.misc
  11.  
  12. Submitted-by: "J. Spencer" <bhgs@utcs.utoronto.ca>
  13. Posting-number: Volume 91, Issue 105
  14. Archive-name: utilities/sman-1.0/part01
  15.  
  16. [ includes uuencoded executable, icon, documentation and library  ...tad ]
  17.  
  18. 'sman' is a manual type program that allows you to specify very general
  19. rules for looking up documentation on a subject.  It has facilities for
  20. searching Amiga AutoDoc format files for an entry, and for scanning through
  21. dme.refs format files, as used by Matt Dillon's DME editor.  As well, of
  22. course, it can look for documentation based on the name of a file (ie. you
  23. say 'sman fred' it might look for 'DOCS:fred.doc' depending on how you
  24. set things up.)
  25.  
  26. 'sless' is a text file viewing program with some features that make it work
  27. particularly well with 'sman'.  I think it as at least as good as more.
  28.  
  29.  
  30. #!/bin/sh
  31. # This is a shell archive.  Remove anything before this line, then unpack
  32. # it by saving it into a file and typing "sh file".  To overwrite existing
  33. # files, type "sh file -c".  You can also feed this as standard input via
  34. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  35. # will see the following message at the end:
  36. #        "End of archive 1 (of 2)."
  37. # Contents:  BUGS_&_REGISTRATION COPYRIGHT.NOTICE OVERVIEW
  38. #   instillation.note sless.doc.uu sman.doc.uu src src/auto_sreg.c
  39. #   src/compilation.notes src/dmakefile src/sless.c src/sless.n
  40. #   src/sless_1.c src/sless_defs.h src/sless_file.c src/sless_help.h
  41. #   src/sless_win.c src/sman.c src/sman.n src/sman_defs.h
  42. # Wrapped by tadguy@ab20 on Fri May 17 21:52:30 1991
  43. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  44. if test -f 'BUGS_&_REGISTRATION' -a "${1}" != "-c" ; then 
  45.   echo shar: Will not clobber existing file \"'BUGS_&_REGISTRATION'\"
  46. else
  47. echo shar: Extracting \"'BUGS_&_REGISTRATION'\" \(324 characters\)
  48. sed "s/^X//" >'BUGS_&_REGISTRATION' <<'END_OF_FILE'
  49. X
  50. XSend bug reports, comments, etc. to
  51. X
  52. X    Jon Spencer.
  53. X
  54. X    EMail:    bhgs@gpu.utcs.utoronto.ca
  55. X
  56. X
  57. XRegistration:
  58. X    The registration fee for these programs is $2654.37, and for this you
  59. X    will receive a birthday card for the rest of my, or your, natural life
  60. X    (whichever ends first).  Please include your birth date ;-).
  61. X
  62. END_OF_FILE
  63. if test 324 -ne `wc -c <'BUGS_&_REGISTRATION'`; then
  64.     echo shar: \"'BUGS_&_REGISTRATION'\" unpacked with wrong size!
  65. fi
  66. # end of 'BUGS_&_REGISTRATION'
  67. fi
  68. if test -f 'COPYRIGHT.NOTICE' -a "${1}" != "-c" ; then 
  69.   echo shar: Will not clobber existing file \"'COPYRIGHT.NOTICE'\"
  70. else
  71. echo shar: Extracting \"'COPYRIGHT.NOTICE'\" \(1144 characters\)
  72. sed "s/^X//" >'COPYRIGHT.NOTICE' <<'END_OF_FILE'
  73. X
  74. X    The programs 'sman', 'sless', and the library 'sregexp.library', and
  75. X    all sources and documentation relating to these programs included in
  76. X    this distribution are Copyright (c) 1991, by Jon Spencer.
  77. X
  78. X    Permission is given to redistribute any part or all of this
  79. X    distribution, either modified or unmodified, PROVIDED THAT:
  80. X    - the distribution is on a not-for-profit basis,
  81. X    - this copyright notice is included in the distribution,
  82. X    - and if a modified version is distributed, clear indication
  83. X      that it is modified is included.
  84. X
  85. X    All other rights are reserved by the author, Jon Spencer.
  86. X
  87. X
  88. X(disclaimer borrowed, somewhat modified, from the DICE distribution)
  89. X
  90. X    PROGRAM DISCLAIMER: THE PROGRAMS AND LIBRARY ARE PROVIDED "AS IS"
  91. X    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  92. X    BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  93. X    FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE RESULTS
  94. X    AND PERFORMANCE OF ANY PROGRAM IS ASSUMED BY YOU.  Should the program
  95. X    prove defective, you assume the entire cost of all necessary servicing,
  96. X    repair, or correction.
  97. X
  98. END_OF_FILE
  99. if test 1144 -ne `wc -c <'COPYRIGHT.NOTICE'`; then
  100.     echo shar: \"'COPYRIGHT.NOTICE'\" unpacked with wrong size!
  101. fi
  102. # end of 'COPYRIGHT.NOTICE'
  103. fi
  104. if test -f 'OVERVIEW' -a "${1}" != "-c" ; then 
  105.   echo shar: Will not clobber existing file \"'OVERVIEW'\"
  106. else
  107. echo shar: Extracting \"'OVERVIEW'\" \(938 characters\)
  108. sed "s/^X//" >'OVERVIEW' <<'END_OF_FILE'
  109. X
  110. X   This is a program that started out as a couple of day project to right a
  111. X'man' style program to look up documentation files. It grew, and it grew...
  112. XAnyway, by the time the dust settled there was a pretty nifty text file
  113. Xviewer and a run-time library for doing wildcards! (sources are a seperate
  114. Xposting.)
  115. X
  116. XThis is what's here:
  117. X
  118. X'sman' is a manual type program that allows you to specify very general
  119. Xrules for looking up documentation on a subject.  It has facilities for
  120. Xsearching Amiga AutoDoc format files for an entry, and for scanning through
  121. Xdme.refs format files, as used by Matt Dillon's DME editor.  As well, of
  122. Xcourse, it can look for documentation based on the name of a file (ie. you
  123. Xsay 'sman fred' it might look for 'DOCS:fred.doc' depending on how you
  124. Xset things up.)
  125. X
  126. X'sless' is a text file viewing program with some features that make it work
  127. Xparticularly well with 'sman'.  I think it as at least as good as more.
  128. X
  129. END_OF_FILE
  130. if test 938 -ne `wc -c <'OVERVIEW'`; then
  131.     echo shar: \"'OVERVIEW'\" unpacked with wrong size!
  132. fi
  133. # end of 'OVERVIEW'
  134. fi
  135. if test -f 'instillation.note' -a "${1}" != "-c" ; then 
  136.   echo shar: Will not clobber existing file \"'instillation.note'\"
  137. else
  138. echo shar: Extracting \"'instillation.note'\" \(125 characters\)
  139. sed "s/^X//" >'instillation.note' <<'END_OF_FILE'
  140. X
  141. X
  142. X    For these programs to work, you must copy the file 'sregexp.library'
  143. X    from this directory to your LIBS: directory.
  144. X
  145. END_OF_FILE
  146. if test 125 -ne `wc -c <'instillation.note'`; then
  147.     echo shar: \"'instillation.note'\" unpacked with wrong size!
  148. fi
  149. # end of 'instillation.note'
  150. fi
  151. if test -f 'sless.doc.uu' -a "${1}" != "-c" ; then 
  152.   echo shar: Will not clobber existing file \"'sless.doc.uu'\"
  153. else
  154. echo shar: Extracting \"'sless.doc.uu'\" \(2281 characters\)
  155. sed "s/^X//" >'sless.doc.uu' <<'END_OF_FILE'
  156. Xbegin 600 sless.doc
  157. XM"B`@("`@4TQ%4U,H,2D@("`@("`@("`@("`@($%-24=!(%!R;V=R86UM97(GX
  158. XM<R!-86YU86P@("`@("`@("`@("`@("!33$534R@Q*0H*"@H@("`@()LQ;4Y!M
  159. XM344@"B`@("`@("`@("";,&US;&5S<R`M(&$@9&]C=6UE;G0@=FEE=VEN9R!P4
  160. XM<F]G<F%M+B`@"@H@("`@()LQ;5-93D]04TE3(`H@("`@("`@("`@<VQE<W,@?
  161. XMFS!M6RUL(&QI;F5N;R!\("UC(&-H87)P;W-=(&9I;&4@"@H@("`@()LQ;41%@
  162. XM4T-225!424].(`H@("`@("`@("`@FS!M5&AE<F4@(&%R92`@<&QE;G1Y("!O8
  163. XM9B!G;V]D('1E>'0@=FEE=VEN9R!P<F]G<F%M<R!A<F]U;F0@9F]R"B`@("`@R
  164. XM("`@("!T:&4@06UI9V$L('=E;&PL(&AE<F4G<R!A;F]T:&5R+B`@"@H@("`@]
  165. XM("`@("`@5&AE(&]R:6=I;F%L(')E87-O;B!F;W(@=W)I=&EN9R";-&US;&5S<
  166. XM<YLP;2!W87,@87,@82`@<VEM<&QE("!T97AT"B`@("`@("`@("!V:65W97(@6
  167. XM('1O("!W;W)K('=I=&@@FS1M<VUA;ILP;2P@=VAI8V@@8V]U;&0@<W1A<G0@I
  168. XM=FEE=VEN9R!A(&9I;&4*("`@("`@("`@(&%T(&%N(&%R8FET<F%R>2!L:6YE`
  169. XM(&YU;6)E<B!O<B!C:&%R86-T97(@<&]S:71I;VXN("!)="!T=7)N<PH@("`@=
  170. XM("`@("`@;W5T+"!A('1E>'0@=FEE=V5R(&ES(&$@8V]M<&QI8V%T960@=&AIC
  171. XM;F<L('-O(&ET(&=R97<@=&\@(&)E"B`@("`@("`@("!A(&QO="!B:6=G97(@I
  172. XM=&AA;B";-&US;6%NFS!M(&ET<V5L9B$@($]H(%=E;&PN+BX@(`H*("`@("`@_
  173. XM("`@(%1H9:!U<V%G9:!I<Z!S=')A:6=H=*!F;W)W87)D+J"@5FEE=R`@82`@7
  174. XM9FEL92!A;F0@:&ET(#QH96QP/@H@("`@("`@("`@=&\@9V5T(&$@:&5L<"!S%
  175. XM8W)E96X@;VX@=&AE(&-O;6UA;F1S+B`@"@H@("`@("`@("`@5&AE(&]N;'D@"
  176. XM=&AI;F<@=&AA="!N965D<R`@82`@;&ET=&QE("!C;&%R:69I8V%T:6]N("!I*
  177. XM<R`@=&AE"B`@("`@("`@("!S96%R8V@@86QG;W)I=&AM+B`@("!)9B`@=&AEY
  178. XM('-E87)C:"!P871T97)N('EO=2!E;G1E<B!H87,@;F\*("`@("`@("`@('5NU
  179. XM97-C87!E9"!W:6QD8V%R9"!C:&%R86-T97)S+"!T:&5N(&$@)R,_)R!W:6QLC
  180. XM(&)E('!R97!E;F1E9`H@("`@("`@("`@86YD(&%P<&5N9&5D('1O('1H92`@`
  181. XM<&%T=&5R;BX@("`@268@(&ET("!H87,@(&%N>2`@=6YE<V-A<&5D"B`@("`@>
  182. XM("`@("!W:6QD8V%R9"`@8VAA<F%C=&5R<RP@=&AE;B!T:&4@<&%T=&5R;B!W;
  183. XM:6QL(&AA=F4@=&\@;6%T8V@@86X*("`@("`@("`@(&5N=&ER9:!L:6YE+J"@K
  184. XM4V5E()LT;7-R96=E>'";,&TNFS1M9&]CFS!M(&9O<B!A(&1I<V-U<W-I;VX@S
  185. XM;V8@=&AE("!L96=A;`H@("`@("`@("`@=VEL9&-A<F0@<WEN=&%X+B`@"@H*B
  186. XM("`@("";,6U3144@04Q33R`*("`@("`@("`@()LP;7-M86XH,2D@"@H*("`@V
  187. XM("";,6U"54<@4D503U)44R`*("`@("`@("`@()LP;5!L96%S92!S96YD(&)UC
  188. XM9R!R97!O<G1S+"!C;VUM96YT<R!E=&,N("!T;R`*"B`@("`@("`@("`@("`@I
  189. XM($IO;B!3<&5N8V5R(`H*("`@("`@("`@("`@("`@14UA:6PZ(&)H9W-`9W!U=
  190. XM+G5T8W,N=71O<F]N=&\N8V$@"@H*"@H*"@H*"@H*"@H*"@H*"@H*"B`@("`@S
  191. XM2F]N(%-P96YC97(@("`@("`@("`@("`@("`@("`@("`@+3$M("`@("`@("`@"
  192. X;("`@("`@("`@("`@("!697)S:6]N(#$N,`H*I
  193. X``
  194. Xend
  195. Xsize 1602
  196. END_OF_FILE
  197. if test 2281 -ne `wc -c <'sless.doc.uu'`; then
  198.     echo shar: \"'sless.doc.uu'\" unpacked with wrong size!
  199. fi
  200. # end of 'sless.doc.uu'
  201. fi
  202. if test -f 'sman.doc.uu' -a "${1}" != "-c" ; then 
  203.   echo shar: Will not clobber existing file \"'sman.doc.uu'\"
  204. else
  205. echo shar: Extracting \"'sman.doc.uu'\" \(7123 characters\)
  206. sed "s/^X//" >'sman.doc.uu' <<'END_OF_FILE'
  207. Xbegin 600 sman.doc
  208. XM"B`@("`@4TU!3B@Q*2`@("`@("`@("`@("`@($%-24=!(%!R;V=R86UM97(G]
  209. XM<R!-86YU86P@("`@("`@("`@("`@("`@4TU!3B@Q*0H*"@H@("`@()LQ;4Y!R
  210. XM344@"B`@("`@("`@("";,&US;6%N("T@82!D;V-U;65N="!L;V]K=7`@<')O;
  211. XM9W)A;2X@(`H*("`@("";,6U364Y/4%-)4R`*("`@("`@("`@('-M86X@FS!M[
  212. XM6RUP(%-E87)C:"!0871T97)N72!;+78@5FEE=V5R72!T87)G970@6W1A<F=E+
  213. XM="XN+ET@"@H@("`@()LQ;41%4T-225!424].(`H@("`@("`@("`@FS!M5&AEO
  214. XM<F4@(&ES("!N;R!U;FEF;W)M('-T86YD87)D(&9O<B!T:&4@9F]R;6%T(&]R3
  215. XM('!O<VET:6]N(&]F"B`@("`@("`@("!D;V-U;65N=&%T:6]N(&9I;&5S("!OP
  216. XM;B`@=&AE("!!;6EG82X@(%1H:7,@(&UA:V5S("!A("!M86YU86P*("`@("`@.
  217. XM("`@('!R;V=R86T@(&EN("!T:&4@('-T>6QE("!O9B`@=&AE(%5N:7@@FS1MW
  218. XM;6%NFS!M('!R;V=R86T@82!S;VUE=VAA=`H@("`@("`@("`@9&EF9FEC=6QT9
  219. XM('1H:6YG('1O(&-R96%T92X@()LT;7-M86Z;,&T@871T96UP=',@=&\@(&]V<
  220. XM97)C;VUE("!T:&ES"B`@("`@("`@("!D:69F:6-U;'1Y("!B>2`@86QL;W=I3
  221. XM;F<@('1H92`@=7-E<B!T;R!S<&5C:69Y('%U:71E(&=E;F5R86P*("`@("`@[
  222. XM("`@(')U;&5S(&9O<B!T:&4@;&]C871I;VX@(&]F("!D;V-U;65N=&%T:6]N[
  223. XM("!F:6QE<RX@("`@3VYC92`@80H@("`@("`@("`@9&]C=6UE;G0@(&ES(&QOG
  224. XM8V%T960L(&ET(&ES('!A<W-E9"!O;B!T;R!A('1E>'0@=FEE=V5R('1O(&)E(
  225. XM"B`@("`@("`@("!D:7-P;&%Y960N("`*"B`@("`@("`@("!4:&5R92!A<F4@[
  226. XM='=O('=A>7,@=&AE(&1O8W5M96YT871I;VX@(&QO;VMU<"`@<G5L97,@(&-A"
  227. XM;B`@8F4*("`@("`@("`@('!A<W-E9"!T;R`@FS1M<VUA;ILP;2X@("!4:&4@T
  228. XM9FER<W0@:7,@8GD@=&AE('5S92!O9B!T:&4@+9LQ;7`@FS!M8V]M;6%N9`H@:
  229. XM("`@("`@("`@;&EN92`@87)G=6UE;G0L("!T:&4@('-E8V]N9"`@:7,@(&)Y+
  230. XM("!T:&4@($5.5CH@(&5N=FER;VYM96YT"B`@("`@("`@("!V87)I86)L92";D
  231. XM,6U3;6%N4&%T:)LP;2X@("!4:&4@8V]M;6%N9"!L:6YE(&%R9W5M96YT('=IK
  232. XM;&P@;W9E<G)I9&4*("`@("`@("`@(&%N>2!D969I;FET:6]N(&]F('1H92!E.
  233. XM;G9I<F]N;65N="!V87)I86)L92P@8G5T(&%T(&QE87-T(&]N90H@("`@("`@'
  234. XM("`@;75S="!B92!D969I;F5D+B`@"@H@("`@("`@("`@5&AE(&9O<FUA="!O:
  235. XM9B!T:&4@;&]O:W5P(')U;&4@:7,Z(`H*("`@("`@("`@("`@("`@<G5L93$['
  236. XM<G5L93([+BXN("`*"B`@("`@("`@("!%86-H(&]F('1H92!R=6QE<R!W:6QLM
  237. XM(&)E('-E87)C:&5D(&EN(&]R9&5R('5N=&EL(&$@;6%T8V@@:7,*("`@("`@Y
  238. XM("`@(&9O=6YD+B`@02!R=6QE(&ES(&9O<FUE9"!B>2!A;B!O<'1I;VYA;"`@L
  239. XM<W!E8VEA;"`@8VAA<F%C=&5R+`H@("`@("`@("`@=VAI8V@@('-P96-I9FEE?
  240. XM<R`@=&AE("!K:6YD(&]F('-E87)C:"!T;R!B92!P97)F;W)M960@;VX@=&AE1
  241. XM"B`@("`@("`@("!M871C:&EN9R!F:6QE<RP@9F]L;&]W960@8GD@82`H<&]S&
  242. XM<VEB;'DI('=I;&1C87)D960@06UI9V%$3U,*("`@("`@("`@('!A=&@@<W!E#
  243. XM8VEF>6EN9R!T:&4@9FEL97,@=&\@8F4@<V5A<F-H960N("!3964@FS1M<W)EW
  244. XM9YLP;2Z;-&UD;V.;,&T@(&9O<@H@("`@("`@("`@82!D:7-C=7-S:6]N(&]F"
  245. XM('1H92!W:6QD8V%R9"!F;W)M870N("`*"B`@("`@("`@("!4:&5R92!A<F4@F
  246. XM8W5R<F5N=&QY('1H<F5E(&MI;F1S(&]F('-E87)C:"!R=6QE<R!I;7!L96UEX
  247. XM;G1E9#H@"@H@("`@("`@("`@()LQ;41E9F%U;'2@FS!M("!)9B`@=&AE("!RQ
  248. XM=6QE("!D;V5S("!N;W0@('-T87)T("!W:71H("!O;F4@;V8@=&AE"B`@("`@N
  249. XM("`@("`@("`@8VAA<F%C=&5R<R!D:7-C=7-S960@8F5L;W<L('1H96X@;F\@X
  250. XM('-P96-I86P@('-E87)C:"`@:7,*("`@("`@("`@("`@("!D;VYE("!O;B!TT
  251. XM:&4@9FEL97,@;VX@=&AE('!A=&@L(&%N9"";-&US;6%NFS!M('=I;&P@<W5CP
  252. XM8V5E9"!O;@H@("`@("`@("`@("`@('1H92!F:7)S="!F:6QE(&9O=6YD+B`@+
  253. XM("!4:&5R92`@:7,@(&$@('-P96-I86P@('=I;&1C87)D"B`@("`@("`@("`@*
  254. XM("`@8VAA<F%C=&5R(&1E9FEN960@(&EN("!S;6%N('1O(&UA:V4@=&AI<R!UP
  255. XM<V5F=6PN("!)9B!T:&4*("`@("`@("`@("`@("!C:&%R86-T97(@)R8G(&ESD
  256. XM(&9O=6YD(&EN('1H92!S96%R8V@@<&%T:"P@(&ET("!W:6QL("!B90H@("`@)
  257. XM("`@("`@("`@(&5X<&%N9&5D('1O("!T:&4@(&-U<G)E;G0@('1A<F=E="X@E
  258. XM("!&;W(@97AA;7!L92P@:68@>6]U"B`@("`@("`@("`@("`@='EP960@("=S5
  259. XM;6%N("!T97-T)R`@86YD("`@FS%M4VUA;E!A=&@@("";,&UW87,@("!D969IF
  260. XM;F5D("`@87,*("`@("`@("`@("`@("`G1$]#4SHN+BXO)BXH9&]C?&UA;BDGR
  261. XM+"`@=&AE;B!T:&4@<&%T:"!S;6%N('=O=6QD('1R>2!T;PH@("`@("`@("`@O
  262. XM("`@(&UA=&-H('=O=6QD(&)E("=$3T-3.BXN+B\H=&5S="DN*&1O8WQM86XI@
  263. XM)RX@(`H*("`@("`@("`@("!`H*!)9B!T:&ES(&ES('1H92!F:7)S="!C:&%RS
  264. XM86-T97(@;V8@=&AE("!R=6QE+"`@=&AE;B`@<VUA;@H@("`@("`@("`@("`@1
  265. XM('=I;&P@87-S=6UE('1H92!M871C:&5D(&9I;&5S(&%R92";-&UD;66;,&TN@
  266. XMFS1M<F5F<YLP;2!F;W)M870@9FEL97,L"B`@("`@("`@("`@("`@87,@=7-EW
  267. XM9"`@8GD@36%T="!$:6QL;VXG<R";-&UD;66;,&T@961I=&]R+B`@5&AE(&9I`
  268. XM;&5S('=I;&P@8F4*("`@("`@("`@("`@("!S96%R8VAE9"!F;W(@86X@96YT)
  269. XM<GD@;6%T8VAI;F<@=&AE('1A<F=E="X@(`H*"@H*"@H*"B`@("`@2F]N(%-P0
  270. XM96YC97(@("`@("`@("`@("`@("`@("`@("`@+3$M("`@("`@("`@("`@("`@X
  271. XM("`@("`@("!697)S:6]N(#$N,`H*"B`@("`@4TU!3B@Q*2`@("`@("`@("`@D
  272. XM("`@($%-24=!(%!R;V=R86UM97(G<R!-86YU86P@("`@("`@("`@("`@("`@S
  273. XM4TU!3B@Q*0H*"B`@("`@("`@("`@*Z"@5&AI<R!T>7!E(&]F(')U;&4@=&5L&
  274. XM;',@()LT;7-M86Z;,&T@('1H92`@;6%T8VAI;F<@(&9I;&5S("!A<F4*("`@#
  275. XM("`@("`@("`@("!!;6EG82!!=71O9&]C("!F;W)M870@9FEL97,N("!%86-H)
  276. XM(&9I;&4@;VX@=&AE('!A=&@@=VEL;`H@("`@("`@("`@("`@(&)E('-E87)C"
  277. XM:"`@9F]R("!A;B`@96YT<GD@(&UA=&-H:6YG("!T:&4@('1A<F=E="X@("`@Q
  278. XM1F]R"B`@("`@("`@("`@("`@97AA;7!L92P@(&EF("";,6U3;6%N4&%T:"`@M
  279. XMFS!M=V%S("`G*T%U=&]D;V-S.B,_+R,_+F1O8R<L('1H96X*("`@("`@("`@T
  280. XM("`@("`G<VUA;B!7<FET92<@=V]U;&0@;6%T8V@@=&\@"B`@("`@("`@("`@-
  281. XM("`@("`@)T%U=&]D;V-S.DQI8G)A<FEE<T$M2R]D;W,N9&]C)R`H=6YD97(@_
  282. XM,2XS(&%N>7=A>2DN("`*"B`@("`@("`@("!!;&P@9FEL92!N86UE('-E87)C^
  283. XM:&5S(&%R92!C87-E(&EN<V5N<VET:79E+B`@($%L;"`@<V5A<F-H97,*("`@$
  284. XM("`@("`@('=I=&AI;B`@82`@9FEL92`@*&9O<B`@)RLG("!A;F0@("=`)R`@=
  285. XM='EP92`@<G5L97,I("!A<F4@8V%S90H@("`@("`@("`@<V5N<VET:79E+B`@<
  286. XM"@H@("`@("`@("`@3VYC92";-&US;6%NFS!M(&AA<R!F;W5N9"!A(&UA=&-HB
  287. XM+"!T:&%T(&9I;&4@:7,@<&%S<V5D(&]N=&\@82!T97AT"B`@("`@("`@("!V?
  288. XM:65W97(@9F]R(&1I<W!L87DN("!4:&4@9&5F875L="!V:65W97(@:7,@FS1MW
  289. XM<VQE<W.;,&TL("!B=70@('1H:7,*("`@("`@("`@(&-A;B`@8F4@;W9E<G)I+
  290. XM9&1E;B!B>2!E:71H97(@=&AE("V;,6UV()LP;6-O;6UA;F0@;&EN92!A<F=UB
  291. XM;65N="!O<@H@("`@("`@("`@=&AE(&5N=FER;VYM96YT('9A<FEA8FQE()LQG
  292. XM;5-M86Y6:65W97*;,&TN("!)9B!T:&4@9&5F875L="`@=FEE=V5R"B`@("`@E
  293. XM("`@("!I<R`@;F]T(&]V97)R:61D96XL('1H96X@8F]T:"`G*R<@86YD("=`:
  294. XM)R!S='EL92!M871C:&5S('=I;&P*("`@("`@("`@('1E;&P@FS1M<VQE<W.;Q
  295. XM,&T@=&\@<W1A<G0@(&1I<W!L87EI;F<@('1H92`@9FEL92`@870@('1H92`@9
  296. XM8V]R<F5C=`H@("`@("`@("`@<&]S:71I;VXN("`@268@('1H92`@9&5F875L@
  297. XM="`@=FEE=V5R(&ES(&]V97)R:61D96XL('1H96X@86QL"B`@("`@("`@("!F8
  298. XM:6QE<R!W:6QL(&)E(&1I<W!L87EE9"!A="!T:&4@9FER<W0@;&EN92X@(`H*S
  299. XM"@H@("`@()LQ;45804U03$53(`H*("`@("`@("`@()LP;45X86UP;&4@FS%M=
  300. XM4VUA;E!A=&@@FS!M=F%R:6%B;&4Z(`H*("`@("`@("`@("`@("`K075T;T1O?
  301. XM8W,Z(S\O(S\N9&]C.T!D8V,Z9&]C+V1M92YR969S.T!D8V,Z;6%N+R!M92YR;
  302. XM969S.R`*("`@("`@("`@("`@("!$3T-3.BXN+B\F*"YD;V-\+FUA;GPN='ATA
  303. XM*2`*"@H@("`@()LQ;4%$1$E424].($-/3E-)1$52051)3TY3(`H*("`@("`@%
  304. XM("`@()LP;9LT;7-M86Z;,&T@=VEL;"!A;'=A>7,@=&%K92!T:&4@9FER<W0@R
  305. XM;6%T8V@@=&AA="!I="!F:6YD<RP@<V\@('1H90H@("`@("`@("`@;W)D97(@$
  306. XM(&]F("!T:&4@(')U;&5S(&-A;B!B92!U<V5D('1O(&UA;FEP=6QA=&4@=&AE?
  307. XM(&]R9&5R(&]F"B`@("`@("`@("!T:&4@<V5A<F-H+B`@"@H@("`@("`@("`@4
  308. XM06QS;RP@)T`G()LT;61M99LP;2Z;-&UR969SFS!M('-T>6QE('-E87)C:&5S$
  309. XM(&%R92!T:&4@9F%S=&5S="X@("!)9B`@>6]U"B`@("`@("`@("!H879E("!T/
  310. XM:&4@()LT;6%U=&]R969SFS!M('!R;V=R86T@9G)O;2!-871T($1I;&QO;B=SH
  311. XM()LT;41)0T6;,&T@<&%C:V%G92P*("`@("`@("`@('EO=2!A<F4@8F5T=&5RF
  312. XM(&]F9B!R=6YN:6YG('1H:7,@(&]N("!Y;W5R("!!=71O9&]C<RP@(')A=&AE"
  313. XM<@H@("`@("`@("`@=&AA;B!U<VEN9R!T:&4@)RLG('-T>6QE('-E87)C:"X@<
  314. XM(`H*"B`@("`@FS%M4T5%($%,4T\@"B`@("`@("`@("";,&US;&5S<R@Q*2`*[
  315. XM"@H@("`@()LQ;4)51R!215!/4E13(`H@("`@("`@("`@FS!M4&QE87-E('-E.
  316. XM;F0@8G5G(')E<&]R=',L(&-O;6UE;G1S(&5T8RX@('1O(`H*("`@("`@("`@2
  317. XM("`@("`@2F]N(%-P96YC97(@"@H@("`@("`@("`@("`@("!%36%I;#H@8FAG^
  318. XM<T!G<'4N=71C<RYU=&]R;VYT;RYC82`*"@H*"@H*"@H@("`@($IO;B!3<&5N-
  319. XM8V5R("`@("`@("`@("`@("`@("`@("`@("TR+2`@("`@("`@("`@("`@("`@F
  320. X3("`@("`@5F5R<VEO;B`Q+C`*"B`@I
  321. X``
  322. Xend
  323. Xsize 5059
  324. END_OF_FILE
  325. if test 7123 -ne `wc -c <'sman.doc.uu'`; then
  326.     echo shar: \"'sman.doc.uu'\" unpacked with wrong size!
  327. fi
  328. # end of 'sman.doc.uu'
  329. fi
  330. if test ! -d 'src' ; then
  331.     echo shar: Creating directory \"'src'\"
  332.     mkdir 'src'
  333. fi
  334. if test -f 'src/auto_sreg.c' -a "${1}" != "-c" ; then 
  335.   echo shar: Will not clobber existing file \"'src/auto_sreg.c'\"
  336. else
  337. echo shar: Extracting \"'src/auto_sreg.c'\" \(419 characters\)
  338. sed "s/^X//" >'src/auto_sreg.c' <<'END_OF_FILE'
  339. X
  340. X#include <clib/exec_protos.h>
  341. X#include <clib/dos_protos.h>
  342. X#include <libraries/sregexpbase.h>
  343. X#include <stdlib.h>
  344. X
  345. Xstruct SregExpBase *SregExpBase;
  346. X
  347. X__autoinit void
  348. Xopensreg()
  349. X{
  350. X    if (!(SregExpBase = OpenLibrary("sregexp.library",7))) {
  351. X    Write(Output(),"Couldn't Open 'sregexp.library'.\n",23);
  352. X    _exit(10);
  353. X    }
  354. X}
  355. X
  356. X__autoexit void
  357. Xclosesreg()
  358. X{
  359. X    if (SregExpBase)
  360. X    CloseLibrary((struct Library *)SregExpBase);
  361. X}
  362. X
  363. END_OF_FILE
  364. if test 419 -ne `wc -c <'src/auto_sreg.c'`; then
  365.     echo shar: \"'src/auto_sreg.c'\" unpacked with wrong size!
  366. fi
  367. # end of 'src/auto_sreg.c'
  368. fi
  369. if test -f 'src/compilation.notes' -a "${1}" != "-c" ; then 
  370.   echo shar: Will not clobber existing file \"'src/compilation.notes'\"
  371. else
  372. echo shar: Extracting \"'src/compilation.notes'\" \(1034 characters\)
  373. sed "s/^X//" >'src/compilation.notes' <<'END_OF_FILE'
  374. X
  375. X    First off, if you look in the dmakefile you will see reference
  376. X    to a file noio_main.c.  This file is just the _main routine
  377. X    that comes with the registered version of DICE with the stuff
  378. X    to setup the stdio files removed, and it has exit() call _exit()
  379. X    directly.  I have no license to go around releasing the the
  380. X    source to Dillon's libraries, so I won't.  But you can easily
  381. X    create the file yourself, or just remove all references to it
  382. X    from the dmake file, and all that will happen is you will have
  383. X    a slightly larger program.
  384. X
  385. X    Besides that,  I made everything under 1.3,  but I have done
  386. X    a couple of things that may make this difficult for you.  First
  387. X    off, I have created a clib directory that has the prototypes
  388. X    to all of the library calls in it.    This also allowed my to
  389. X    created a registered args version of the 1.3 Amiga.lib linker
  390. X    library.  The easiest thing to do would just be to make
  391. X    a stack argument version, other than that, I leave it up
  392. X    to your ingenuity.
  393. X
  394. END_OF_FILE
  395. if test 1034 -ne `wc -c <'src/compilation.notes'`; then
  396.     echo shar: \"'src/compilation.notes'\" unpacked with wrong size!
  397. fi
  398. # end of 'src/compilation.notes'
  399. fi
  400. if test -f 'src/dmakefile' -a "${1}" != "-c" ; then 
  401.   echo shar: Will not clobber existing file \"'src/dmakefile'\"
  402. else
  403. echo shar: Extracting \"'src/dmakefile'\" \(1096 characters\)
  404. sed "s/^X//" >'src/dmakefile' <<'END_OF_FILE'
  405. X
  406. X# For no registered args
  407. X#REGARG =
  408. X
  409. X# For registered args.
  410. XREGARG = -mRR
  411. X
  412. X# For a lot of junk
  413. X#DEBUG = -D __DEBUG -D __TRACE__
  414. X
  415. X# For a bit of junk
  416. X#DEBUG = -D __DEBUG__
  417. X
  418. X# for no junk.
  419. XDEBUG =
  420. X
  421. XCC = dcc
  422. XCCOPTS = -I$(OD) $(DEBUG) $(REGARG) -ms -proto -c
  423. XLINKOPTS = -r $(REGARG) -l sregexpsr.lib
  424. X
  425. X# A convinient place for the object files.
  426. XOD = OBJS:sman/
  427. X
  428. X
  429. X
  430. XSLESS_SRC = sless.c sless_1.c sless_win.c sless_file.c \
  431. X        auto_sreg.c noio_main.c
  432. X
  433. XSMAN_SRC = sman.c
  434. X
  435. XSLESS_OBJS = $(SLESS_SRC:"*.c":"$(OD)*.o")
  436. XSMAN_OBJS =  $(SMAN_SRC:"*.c":"$(OD)*.o")
  437. X
  438. X
  439. X
  440. X
  441. Xall: /sless /sman
  442. X
  443. X/sless: $(OD)sless_proto.h $(SLESS_OBJS)
  444. X    -Delete >NIL: %(left)
  445. X    $(CC) $(LINKOPTS) -o%(left) $(SLESS_OBJS)
  446. X
  447. X/sman: $(SMAN_OBJS) $(OD)auto_sreg.o
  448. X    -Delete >NIL: %(left)
  449. X    $(CC) $(LINKOPTS) -o%(left) $(SMAN_OBJS) $(OD)auto_sreg.o
  450. X
  451. X
  452. X
  453. X$(SMAN_OBJS) : $(SMAN_SRC)
  454. X    -Delete >NIL: %(left)
  455. X    $(CC) $(CCOPTS) -o%(left) %(right)
  456. X
  457. X$(SLESS_OBJS) : $(SLESS_SRC)
  458. X    -Delete >NIL: %(left)
  459. X    $(CC) $(CCOPTS) -o%(left) %(right)
  460. X
  461. X$(OD)sless_proto.h : $(SLESS_SRC)
  462. X    -Delete >NIL: %(left)
  463. X    makeproto -o%(left) %(right)
  464. END_OF_FILE
  465. if test 1096 -ne `wc -c <'src/dmakefile'`; then
  466.     echo shar: \"'src/dmakefile'\" unpacked with wrong size!
  467. fi
  468. # end of 'src/dmakefile'
  469. fi
  470. if test -f 'src/sless.c' -a "${1}" != "-c" ; then 
  471.   echo shar: Will not clobber existing file \"'src/sless.c'\"
  472. else
  473. echo shar: Extracting \"'src/sless.c'\" \(5955 characters\)
  474. sed "s/^X//" >'src/sless.c' <<'END_OF_FILE'
  475. X
  476. X#include "sless_defs.h"
  477. X#include <libraries/sregexpbase.h>
  478. X#include <string.h>
  479. X#include <stdlib.h>
  480. X#include <ctype.h>
  481. X#include <clib/dos_protos.h>
  482. X
  483. XPrototype void            usage(void);
  484. XPrototype void            refreshscreen(void);
  485. XPrototype void            waitcommand(void);
  486. XPrototype void            leave(int, char *);
  487. XPrototype int            putline(void);
  488. X
  489. Xconst char memory[] = "sless: Unable to allocate memory.\n";
  490. Xconst char end[]    = " \x9b7m-- END OF FILE --\x9b0m";
  491. Xconst char top[]    = " \x9b7m-- TOP OF FILE --\x9b0m";
  492. Xconst char nopat[]  = " \x9b7m-- Pattern not found --\x9b0m";
  493. Xconst char nolast[] = " \x9b7m-- No previous pattern --\x9b0m";
  494. Xconst char wait[]   = " \x9b7m-- Searching --\x9b0m";
  495. Xconst char abort[]  = " \x9b7m-- Search aborted --\x9b0m";
  496. X
  497. Xchar seek = 0;
  498. Xlong startpos = 0,nextpos = 0;
  499. XFILE *file = NULL,*ofile = NULL;
  500. XBPTR con = 0;
  501. Xint sx,sy;
  502. Xstruct SregExp *lastspat = NULL;
  503. X
  504. Xint main(ac,av)
  505. Xint ac;
  506. Xchar **av;
  507. X{
  508. X    int line = 0,i;
  509. X    char *p,*oldwin = NULL;
  510. X
  511. X    show_line;
  512. X    while (ac > 0) {
  513. X    ac--;
  514. X    av++;
  515. X    if (**av != '-')
  516. X        break;
  517. X    switch (*(*av+1)) {
  518. X        case ('l') :
  519. X        if (line != 0)
  520. X            usage();
  521. X        p = *av+2;
  522. X        while (isdigit(*p))
  523. X            line = line*10 + *p++ - '0';
  524. X        break;
  525. X        case ('c') :
  526. X        if (line != 0)
  527. X            usage();
  528. X        p = *av+2;
  529. X        while (isdigit(*p))
  530. X            line = line*10 - *p++ + '0';
  531. X        break;
  532. X        default :
  533. X        usage();
  534. X    }
  535. X    }
  536. X
  537. X    if (ac < 1)
  538. X    usage();
  539. X    if (!(file = sopen(*av)))
  540. X    leave(15,"Unable to open input stream.\n");
  541. X
  542. X    /* try and find the length of a file.  If it fails or is zero, then
  543. X       we assume we cannot seek into the file.    This catches trying to
  544. X       seek into pipes. */
  545. X    sseek(file,0,SEEK_END);
  546. X    if (stell(file) <= 0)
  547. X    seek = 0;
  548. X    else {
  549. X    seek = 1;
  550. X    sseek(file,0,SEEK_SET);
  551. X    }
  552. X
  553. X    con = makeoutput(*av);
  554. X
  555. X    if (line < 0) {
  556. X    startpos = -line;
  557. X    if (seek)
  558. X        sseek(file,startpos,SEEK_SET);
  559. X    else
  560. X        for (i = 0; i > line; i--)
  561. X        getc(file);
  562. X    } else {
  563. X    for (i = 0; i < line && (p = sgetline(file)); i++) {
  564. X        show_line;
  565. X        free(p);
  566. X        show_line;
  567. X        if (seek)
  568. X        startpos = stell(file);
  569. X    }
  570. X    }
  571. X
  572. X    findsize(&sx,&sy,con);
  573. X    refreshscreen();
  574. X    waitcommand();
  575. X
  576. X    closeoutput(con);
  577. X    con = 0;
  578. X    sclose(file);
  579. X    file = NULL;
  580. X    return 0;
  581. X}
  582. X
  583. Xvoid
  584. Xusage()
  585. X{
  586. X    show_line;
  587. X    sputs("sless V"\
  588. X      VERSION\
  589. X      ", "\
  590. X      __DATE__\
  591. X      ", \xA9Copyright 1991 by Jon Spencer.\n");
  592. X    sputs("Usage: sless [-llineno | -ccharpos] file\n");
  593. X    sputs("Where lineno is the optional starting line number,\n");
  594. X    sputs("or charpos is the optional starting character positon.\n");
  595. X    exit(2);
  596. X}
  597. X
  598. Xvoid
  599. Xleave(x,p)
  600. Xint x;
  601. Xchar *p;
  602. X{
  603. X    show_line;
  604. X    sputs(p);
  605. X    closeoutput(con);
  606. X    if (con)
  607. X    closeoutput(con);
  608. X    if (file)
  609. X    sclose(file);
  610. X    if (ofile)
  611. X    sclose(ofile);
  612. X    exit(x);
  613. X}
  614. X
  615. Xvoid
  616. Xwaitcommand()
  617. X{
  618. X    short c;
  619. X
  620. X    show_line;
  621. X    do {
  622. X    switch (c = getconchar(con)) {
  623. X        case (' ') :
  624. X        sgetcur(file);
  625. X        if (seof(file) && nextpos > 0)
  626. X            nextpos = -1;
  627. X        if (nextpos >= 0) {
  628. X            startpos = nextpos;
  629. X            refreshscreen();
  630. X        } else {
  631. X            bottomline();
  632. X            if (nextpos-- == -2)
  633. X            return;
  634. X            putconstr(end,con);
  635. X        }
  636. X        break;
  637. X        case ('<') :
  638. X        case (makeconid('T',0)) :
  639. X        if (seek) {
  640. X            if (startpos == 0) {
  641. X            bottomline();
  642. X            putconstr(top,con);
  643. X            } else {
  644. X            startpos = 0;
  645. X            refreshscreen();
  646. X            }
  647. X        }
  648. X        break;
  649. X        case (13) :
  650. X        case (makeconid('B',0)) :
  651. X        sgetcur(file);
  652. X        if (seof(file) && nextpos > 0)
  653. X            nextpos = -1;
  654. X        if (nextpos >= 0) {
  655. X            downone();
  656. X        } else {
  657. X            bottomline();
  658. X            if (nextpos-- == -2)
  659. X            return;
  660. X            putconstr(end,con);
  661. X        }
  662. X        break;
  663. X        case ('q') :
  664. X        bottomline();
  665. X        return;
  666. X        case (8) :
  667. X        case ('b') :
  668. X        if (seek) {
  669. X            if (startpos == 0) {
  670. X            bottomline();
  671. X            putconstr(top,con);
  672. X            } else
  673. X            backup(sy-2);
  674. X        }
  675. X        break;
  676. X        case ('d') :
  677. X        sgetcur(file);
  678. X        if (seof(file) && nextpos > 0)
  679. X            nextpos = -1;
  680. X        if (nextpos >= 0) {
  681. X            int i = 1;
  682. X
  683. X            while (i++ < sy/2 && nextpos > 0)
  684. X            startpos = skiponeline(startpos);
  685. X            refreshscreen();
  686. X        } else {
  687. X            bottomline();
  688. X            if (nextpos-- == -2)
  689. X            return;
  690. X            putconstr(end,con);
  691. X        }
  692. X        break;
  693. X        case ('>') :
  694. X        case (makeconid('S',0)) :
  695. X        if (seek) {
  696. X            sseek(file,-1,SEEK_END);
  697. X            startpos = stell(file);
  698. X            backup(sy-1);
  699. X        }
  700. X        break;
  701. X        case ('u') :
  702. X        if (seek) {
  703. X            if (startpos != 0) {
  704. X            backup(sy/2-1);
  705. X            } else {
  706. X            bottomline();
  707. X            putconstr(top,con);
  708. X            }
  709. X        }
  710. X        break;
  711. X        case (makeconid('A',0)) :
  712. X        if (seek) {
  713. X            if (startpos != 0) {
  714. X            uponeline();
  715. X            } else {
  716. X            bottomline();
  717. X            putconstr(top,con);
  718. X            }
  719. X        }
  720. X        break;
  721. X        case ('/') :
  722. X        if (seek) {
  723. X            bottomline();
  724. X            putconstr("/",con);
  725. X            if (!searchfor())
  726. X            break;
  727. X            nextpat();
  728. X        }
  729. X        break;
  730. X        case ('n') :
  731. X        if (seek)
  732. X            nextpat();
  733. X        break;
  734. X        case ('p') :
  735. X        if (seek)
  736. X            prevpat();
  737. X        break;
  738. X        case (';') :
  739. X        if (seek) {
  740. X            bottomline();
  741. X            putconstr(";",con);
  742. X            if (!searchfor())
  743. X            break;
  744. X            prevpat();
  745. X        }
  746. X        break;
  747. X        case (makeconid('?','~')) :
  748. X        case ('h') :
  749. X        case ('?') :
  750. X        if (!ofile)
  751. X            behelpfull();
  752. X        break;
  753. X    }
  754. X    } while (TRUE);
  755. X}
  756. X
  757. Xvoid
  758. Xrefreshscreen()
  759. X{
  760. X    int y,c;
  761. X    long t;
  762. X
  763. X    show_line;
  764. X    putconstr("\x9b0 p\x0c",con);
  765. X
  766. X    y = sy;
  767. X    if (seek)
  768. X    sseek(file,startpos,SEEK_SET);
  769. X    do {
  770. X    if (seek && y > 1)
  771. X        nextpos = stell(file);
  772. X    } while (--y > 0 && !(c = putline()));
  773. X
  774. X    if (seof(file))
  775. X    nextpos = -1;
  776. X    if (c == 2) {
  777. X    nextpos = stell(file);
  778. X    }
  779. X
  780. X    while (--y > 0)
  781. X    putconchar(10,con);
  782. X
  783. X    putconstr(": \x9b p",con);
  784. X}
  785. X
  786. Xint
  787. Xputline()
  788. X{
  789. X    char *p,*q;
  790. X
  791. X    show_line;
  792. X
  793. X    if (!(p = sgetline(file))) {
  794. X    putconchar(10,con);
  795. X    return TRUE;
  796. X    }
  797. X    q = skipdispline(p);
  798. X    if (*(q-1) == 12) {
  799. X    *(q-1) = 0;
  800. X    putconstr(p,con);
  801. X    putconstr("^L\n",con);
  802. X    free(p);
  803. X    return 2;
  804. X    } else if (*q) {
  805. X    sseek(file,q - p - strlen(p),SEEK_CUR);
  806. X    *q++ = '\n';
  807. X    *q = 0;
  808. X    }
  809. X    putconstr(p,con);
  810. X    free(p);
  811. X    return seof(file);
  812. X}
  813. END_OF_FILE
  814. if test 5955 -ne `wc -c <'src/sless.c'`; then
  815.     echo shar: \"'src/sless.c'\" unpacked with wrong size!
  816. fi
  817. # end of 'src/sless.c'
  818. fi
  819. if test -f 'src/sless.n' -a "${1}" != "-c" ; then 
  820.   echo shar: Will not clobber existing file \"'src/sless.n'\"
  821. else
  822. echo shar: Extracting \"'src/sless.n'\" \(1193 characters\)
  823. sed "s/^X//" >'src/sless.n' <<'END_OF_FILE'
  824. X.*
  825. X.*
  826. X.TH SLESS 1 "AMIGA Programmer's Manual" "Jon Spencer" "Version 1.0"
  827. X.SH NAME
  828. Xsless - a document viewing program.
  829. X.SH SYNOPSIS
  830. X.bo "sless
  831. X[-l lineno | -c charpos] file
  832. X.SH DESCRIPTION
  833. XThere are plenty of good text viewing programs around for the Amiga,
  834. Xwell, here's another.
  835. X
  836. XThe original reason for writing
  837. X.ul "sless
  838. Xwas as a simple text viewer
  839. Xto work with
  840. X.ul "sman,
  841. Xwhich could start viewing a file at an arbitrary line number or
  842. Xcharacter position.  It turns out, a text viewer is a complicated
  843. Xthing, so it grew to be a lot bigger than
  844. X.ul "sman
  845. Xitself!  Oh Well...
  846. X
  847. XThe usage is straight forward.    View a file and hit <help> to
  848. Xget a help screen on the commands.
  849. X
  850. XThe only thing that needs a little clarification is the search
  851. Xalgorithm.  If the search pattern you enter has no unescaped
  852. Xwildcard characters, then a '#?' will be prepended and appended to
  853. Xthe pattern.  If it has any unescaped wildcard characters, then
  854. Xthe pattern will have to match an entire line.    See
  855. X.ul "sregexp.doc
  856. Xfor a discussion of the legal wildcard syntax.
  857. X
  858. X.SH "SEE ALSO"
  859. Xsman(1)
  860. X
  861. X.SH "BUG REPORTS"
  862. XPlease send bug reports, comments etc. to
  863. X.in +5
  864. X
  865. XJon Spencer
  866. X
  867. XEMail: bhgs@@gpu.utcs.utoronto.ca
  868. X.in-5
  869. X
  870. END_OF_FILE
  871. if test 1193 -ne `wc -c <'src/sless.n'`; then
  872.     echo shar: \"'src/sless.n'\" unpacked with wrong size!
  873. fi
  874. # end of 'src/sless.n'
  875. fi
  876. if test -f 'src/sless_1.c' -a "${1}" != "-c" ; then 
  877.   echo shar: Will not clobber existing file \"'src/sless_1.c'\"
  878. else
  879. echo shar: Extracting \"'src/sless_1.c'\" \(6670 characters\)
  880. sed "s/^X//" >'src/sless_1.c' <<'END_OF_FILE'
  881. X
  882. X#include "sless_defs.h"
  883. X#include <libraries/sregexpbase.h>
  884. X#include <string.h>
  885. X#include <stdlib.h>
  886. X#include <ctype.h>
  887. X#include <exec/execbase.h>
  888. X#include <clib/dos_protos.h>
  889. X#include <clib/exec_protos.h>
  890. X#include <clib/sregexp_protos.h>
  891. X
  892. XPrototype void            backup(int);
  893. XPrototype char *        getbackline(int *);
  894. XPrototype int            displines(char *);
  895. XPrototype char *        skipdispline(char *);
  896. XPrototype void            downone(void);
  897. XPrototype long            skiponeline(long);
  898. XPrototype int            breakfn(void);
  899. XPrototype void            bottomline(void);
  900. XPrototype int            searchfor(void);
  901. XPrototype void            nextpat(void);
  902. XPrototype void            prevpat(void);
  903. XPrototype void            behelpfull(void);
  904. XPrototype void            chkabort(void);
  905. XPrototype void            uponeline(void);
  906. X
  907. Xextern const char memory[],nolast[],nopat[],wait[],abort[];
  908. X
  909. Xextern char seek;
  910. Xextern long startpos,nextpos;
  911. Xextern FILE *file,*ofile;
  912. Xextern BPTR con;
  913. Xextern int sx,sy;
  914. Xextern struct SregExp *lastspat;
  915. X
  916. Xextern struct ExecBase *SysBase;
  917. X
  918. Xvoid
  919. Xbackup(n)
  920. Xint n;
  921. X{
  922. X    char *p,*q,*h;
  923. X    int l = 0;
  924. X
  925. X    show_line;
  926. X    do {
  927. X    if (l)
  928. X        free(p);
  929. X    if (!(p = getbackline(&startpos)))
  930. X        break;
  931. X    l += displines(p);
  932. X    } while (l < n);
  933. X
  934. X    h = p;
  935. X    while (l > n) {
  936. X    q = skipdispline(p);
  937. X    startpos += q - p;
  938. X    p = q;
  939. X    l-- ;
  940. X    }
  941. X    if (h)
  942. X    free(h);
  943. X    refreshscreen();
  944. X}
  945. X
  946. Xchar *
  947. Xgetbackline(pos)
  948. Xlong *pos;
  949. X{
  950. X    char *p,c;
  951. X    int l = 0;
  952. X
  953. X    show_line;
  954. X    if (*pos == 0)
  955. X    return NULL;
  956. X    sseekbot(file,*pos-1);
  957. X    while (*pos > 0) {
  958. X    c = sgetcur(file);
  959. X    if (c == '\n' && l != 0) {
  960. X        sseek(file,+1,SEEK_CUR);
  961. X        break;
  962. X    }
  963. X    sseek(file,-1,SEEK_CUR);
  964. X    l++;
  965. X    (*pos)--;
  966. X    }
  967. X    if (!(p = malloc(l+1)))
  968. X    leave(12,memory);
  969. X    sgets(p,l+1,file);
  970. X    return p;
  971. X}
  972. X
  973. Xint
  974. Xdisplines(p)
  975. Xchar *p;
  976. X{
  977. X    int l = 1;
  978. X
  979. X    show_line;
  980. X    while (*(p = skipdispline(p))) l++;
  981. X    return l;
  982. X}
  983. X
  984. Xchar *
  985. Xskipdispline(p)
  986. Xchar *p;
  987. X{
  988. X    int l = 0;
  989. X
  990. X    show_line;
  991. X    while (*p && l < sx) {
  992. X    switch (*p++) {
  993. X        case (12) :
  994. X        return (l + 2 <= sx) ? p : p - 1;
  995. X        case ((char)0x1b) :
  996. X        if (*p != '[')
  997. X            break;
  998. X        p++;
  999. X        case ((char)0x9b) :
  1000. X        while (isdigit(*p) || *p == ';' || *p == ' ')
  1001. X            p++;
  1002. X        p++;
  1003. X        break;
  1004. X        case (9) :
  1005. X        l = (l + 8) & (~7);
  1006. X        if (l > sx)
  1007. X            return p-1;
  1008. X        break;
  1009. X        case ('\n') :
  1010. X        return p;
  1011. X        default :
  1012. X        l++;
  1013. X    }
  1014. X    }
  1015. X    while ((*p == 0x1B && *(p+1) == '[') || *p == (char)0x9b) {
  1016. X    if (*p == 0x1b)
  1017. X        p++;
  1018. X    do {
  1019. X        p++;
  1020. X    } while (isdigit(*p) || *p == ';' || *p == ' ');
  1021. X    p++;
  1022. X    }
  1023. X    if (*p == '\n')
  1024. X    p++;
  1025. X    return p;
  1026. X}
  1027. X
  1028. Xvoid
  1029. Xdownone()
  1030. X{
  1031. X    int pos;
  1032. X
  1033. X    show_line;
  1034. X    if (seek) {
  1035. X    pos = stell(file);
  1036. X    startpos = skiponeline(startpos);
  1037. X    sseek(file,pos,SEEK_SET);
  1038. X    }
  1039. X    bottomline();
  1040. X    if (seek)
  1041. X    nextpos = stell(file);
  1042. X    putline();
  1043. X    if (seof(file))
  1044. X    nextpos = -1;
  1045. X    putconstr(": ",con);
  1046. X}
  1047. X
  1048. Xlong
  1049. Xskiponeline(pos)
  1050. Xlong pos;
  1051. X{
  1052. X    char *p,*q;
  1053. X
  1054. X    show_line;
  1055. X    sseek(file,pos,SEEK_SET);
  1056. X    if (!(p = sgetline(file)))
  1057. X    return pos;
  1058. X    q = skipdispline(p);
  1059. X    free(p);
  1060. X    return pos + q - p;
  1061. X}
  1062. X
  1063. Xvoid
  1064. Xuponeline()
  1065. X{
  1066. X    char *p,*h,*q;
  1067. X    int l,j;
  1068. X    long t;
  1069. X
  1070. X    h = p = getbackline(&startpos);
  1071. X    l = displines(p);
  1072. X    while (l > 1) {
  1073. X    q = skipdispline(p);
  1074. X    startpos += q - p;
  1075. X    p = q;
  1076. X    l--;
  1077. X    }
  1078. X    free(h);
  1079. X    if (nextpos < 0) {
  1080. X    sseek(file,startpos,SEEK_SET);
  1081. X    l = 0;
  1082. X    while ((p = sgetline(file)) && (l += displines(p)) < sy - 2) {
  1083. X        free(p);
  1084. X    }
  1085. X    if (p) {
  1086. X        nextpos = stell(file);
  1087. X        if (l > sy - 2) {
  1088. X        j = displines(p);
  1089. X        q = p;
  1090. X        while (l - j < sy - 2) {
  1091. X            q = skipdispline(q);
  1092. X            j--;
  1093. X        }
  1094. X        nextpos -= p + strlen(p) - q;
  1095. X        }
  1096. X        free(p);
  1097. X    } else
  1098. X        nextpos = -1;
  1099. X    } else {
  1100. X    h = p = getbackline(&nextpos);
  1101. X    l = displines(p);
  1102. X    while (l > 1) {
  1103. X        q = skipdispline(p);
  1104. X        nextpos += q - p;
  1105. X        p = q;
  1106. X        l-- ;
  1107. X    }
  1108. X    free(h);
  1109. X    }
  1110. X    sseek(file,startpos,SEEK_SET);
  1111. X    putconstr("\x9b0 p\x9bT\x9b0;0;H",con);
  1112. X    putline();
  1113. X    bottomline();
  1114. X    putconstr(": \x9b p",con);
  1115. X    t = skiponeline(nextpos);
  1116. X    sseek(file,t,SEEK_SET);
  1117. X}
  1118. X
  1119. Xint
  1120. Xbreakfn()
  1121. X{
  1122. X    show_line;
  1123. X    if (con) {
  1124. X    while (WaitForChar(con,100))
  1125. X        rawreadcon(con);
  1126. X    }
  1127. X    leave(5,"***BREAK***\n");
  1128. X}
  1129. X
  1130. Xvoid
  1131. Xbottomline()
  1132. X{
  1133. X    show_line;
  1134. X    putconchar('\x9b',con);
  1135. X    putconint(sy,con);
  1136. X    putconstr(";0H\x9bK",con);
  1137. X}
  1138. X
  1139. Xint
  1140. Xsearchfor()
  1141. X{
  1142. X    char *pat,buff[204];
  1143. X    struct SregExp *spat;
  1144. X
  1145. X    show_line;
  1146. X    if (!(pat = getstr(con))) {
  1147. X    bottomline();
  1148. X    putconstr(": ",con);
  1149. X    return FALSE;
  1150. X    }
  1151. X    if (!IsWild(pat)) {
  1152. X    strcpy(buff,"#?");
  1153. X    strcat(buff,pat);
  1154. X    strcat(buff,"#?");
  1155. X    } else {
  1156. X    strcpy(buff,pat);
  1157. X    strcat(buff,"\n");
  1158. X    }
  1159. X    free(pat);
  1160. X    if (!(spat = ParseSregExp(buff)))
  1161. X    return FALSE;
  1162. X    if (lastspat)
  1163. X    FreeSregExp(lastspat);
  1164. X    lastspat = spat;
  1165. X    return TRUE;
  1166. X}
  1167. X
  1168. Xvoid
  1169. Xnextpat()
  1170. X{
  1171. X    long h,i;
  1172. X    char *p;
  1173. X    struct Task *task = SysBase->ThisTask;
  1174. X
  1175. X    show_line;
  1176. X    if (!lastspat) {
  1177. X    bottomline();
  1178. X    putconstr(nolast,con);
  1179. X    return;
  1180. X    }
  1181. X    bottomline();
  1182. X    putconstr(wait,con);
  1183. X    h = startpos;
  1184. X    i = stell(file);
  1185. X    sseek(file,startpos,SEEK_SET);
  1186. X    p = sgetline(file);
  1187. X    free(p);
  1188. X    startpos = stell(file);
  1189. X    while (p = sgetline(file)) {
  1190. X    if (MatchSregExp(p,lastspat,FALSE)) {
  1191. X        free(p);
  1192. X        refreshscreen();
  1193. X        return;
  1194. X    }
  1195. X    free(p);
  1196. X    startpos = stell(file);
  1197. X    if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
  1198. X        SetSignal(0, SIGBREAKF_CTRL_C);
  1199. X        bottomline();
  1200. X        putconstr(abort,con);
  1201. X        goto done;
  1202. X    }
  1203. X    }
  1204. X    bottomline();
  1205. X    putconstr(nopat,con);
  1206. Xdone:
  1207. X    startpos = h;
  1208. X    sseek(file,i,SEEK_SET);
  1209. X}
  1210. X
  1211. Xvoid
  1212. Xprevpat()
  1213. X{
  1214. X    long h,i;
  1215. X    char *p;
  1216. X    struct Task *task = SysBase->ThisTask;
  1217. X
  1218. X    show_line;
  1219. X    if (!lastspat) {
  1220. X    bottomline();
  1221. X    putconstr(nolast,con);
  1222. X    return;
  1223. X    }
  1224. X    bottomline();
  1225. X    putconstr(wait,con);
  1226. X    h = startpos;
  1227. X    i = stell(file);
  1228. X    while (p = getbackline(&startpos)) {
  1229. X    if (MatchSregExp(p,lastspat,FALSE)) {
  1230. X        free(p);
  1231. X        refreshscreen();
  1232. X        return;
  1233. X    }
  1234. X    free(p);
  1235. X    if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
  1236. X        SetSignal(0, SIGBREAKF_CTRL_C);
  1237. X        bottomline();
  1238. X        putconstr(abort,con);
  1239. X        goto done;
  1240. X    }
  1241. X    }
  1242. X    bottomline();
  1243. X    putconstr(nopat,con);
  1244. Xdone:
  1245. X    startpos = h;
  1246. X    sseek(file,i,SEEK_SET);
  1247. X}
  1248. X
  1249. Xvoid
  1250. Xbehelpfull()
  1251. X{
  1252. X    char oseek;
  1253. X    long ostartpos,onextpos;
  1254. X
  1255. X    show_line;
  1256. X    ofile = file;
  1257. X    oseek = seek;
  1258. X    ostartpos = startpos;
  1259. X    onextpos = nextpos;
  1260. X    seek = TRUE;
  1261. X    file = sopen(NULL);
  1262. X    startpos = 0;
  1263. X    refreshscreen();
  1264. X    waitcommand();
  1265. X    sclose(file);
  1266. X    file = ofile;
  1267. X    ofile = NULL;
  1268. X    seek = oseek;
  1269. X    startpos = ostartpos;
  1270. X    nextpos = onextpos;
  1271. X    refreshscreen();
  1272. X}
  1273. X
  1274. Xvoid
  1275. Xchkabort(void)
  1276. X{
  1277. X    struct Task *task = SysBase->ThisTask;
  1278. X
  1279. X    if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
  1280. X    SetSignal(0, SIGBREAKF_CTRL_C);
  1281. X    breakfn();
  1282. X    }
  1283. X}
  1284. X
  1285. END_OF_FILE
  1286. if test 6670 -ne `wc -c <'src/sless_1.c'`; then
  1287.     echo shar: \"'src/sless_1.c'\" unpacked with wrong size!
  1288. fi
  1289. # end of 'src/sless_1.c'
  1290. fi
  1291. if test -f 'src/sless_defs.h' -a "${1}" != "-c" ; then 
  1292.   echo shar: Will not clobber existing file \"'src/sless_defs.h'\"
  1293. else
  1294. echo shar: Extracting \"'src/sless_defs.h'\" \(975 characters\)
  1295. sed "s/^X//" >'src/sless_defs.h' <<'END_OF_FILE'
  1296. X
  1297. X#define Prototype   extern
  1298. X
  1299. X#include <exec/types.h>
  1300. X#include <libraries/dos.h>
  1301. X
  1302. X#ifdef __DEBUG__
  1303. X#ifdef __TRACE__
  1304. Xstatic const char __BaseFile[] = __BASE_FILE__;
  1305. X#define     show_line        reportline(__BaseFile,__LINE__)
  1306. X#else  (__TRACE__)
  1307. X#define     show_line
  1308. X#endif (__TRACE__)
  1309. X#else (__DEBUG__)
  1310. X#define     show_line
  1311. X#endif (__DEBUG__)
  1312. X
  1313. X
  1314. X#define VERSION     "1.0"
  1315. X
  1316. X#define MAXLINE     400
  1317. X
  1318. X#define makeconid(a,b)      ( ((short)(a) << 8) + (b) )
  1319. X
  1320. Xstruct conreport {
  1321. X    short    conid;
  1322. X    int     args[8];
  1323. X};
  1324. X
  1325. X
  1326. X
  1327. X#define getc(fp)        (((fp)->unget!=0x100||(fp)->pos>=(fp)->bufflen)?sgetc(fp):(fp)->buff[(fp)->pos++])
  1328. X#define seof(fp)        ((fp)->bufflen<=0)
  1329. X#define stell(fp)       ((fp)->filepos+(fp)->pos)
  1330. X#define ungetc(c,fp)    ((fp)->pos--,fp->unget=(c))
  1331. X
  1332. X#define SEEK_SET    0
  1333. X#define SEEK_CUR    1
  1334. X#define SEEK_END    2
  1335. X
  1336. Xtypedef struct file {
  1337. X    int     filepos,pos,bufflen;
  1338. X    BPTR    des;
  1339. X    short   unget;
  1340. X    char    *buff;
  1341. X} FILE;
  1342. X
  1343. X#include "sless_proto.h"
  1344. END_OF_FILE
  1345. if test 975 -ne `wc -c <'src/sless_defs.h'`; then
  1346.     echo shar: \"'src/sless_defs.h'\" unpacked with wrong size!
  1347. fi
  1348. # end of 'src/sless_defs.h'
  1349. fi
  1350. if test -f 'src/sless_file.c' -a "${1}" != "-c" ; then 
  1351.   echo shar: Will not clobber existing file \"'src/sless_file.c'\"
  1352. else
  1353. echo shar: Extracting \"'src/sless_file.c'\" \(5265 characters\)
  1354. sed "s/^X//" >'src/sless_file.c' <<'END_OF_FILE'
  1355. X
  1356. X#include "sless_defs.h"
  1357. X#include "sless_help.h"
  1358. X#include <stdlib.h>
  1359. X#include <string.h>
  1360. X#include <libraries/dos.h>
  1361. X#include <clib/dos_protos.h>
  1362. X
  1363. Xextern const char memory[];
  1364. X
  1365. XPrototype FILE *        sopen(char *);
  1366. XPrototype void            sclose(FILE *);
  1367. XPrototype char *        sgets(char *, int, FILE *);
  1368. XPrototype char *        sgetline(FILE *);
  1369. XPrototype char            sgetc(FILE *);
  1370. XPrototype void            sseek(FILE *, int, int);
  1371. XPrototype char            sgetcur(FILE *);
  1372. XPrototype void            sseekbot(FILE *, int);
  1373. XPrototype void            sputs(char *);
  1374. X
  1375. X#define FILEBUFF    2048
  1376. X
  1377. XFILE *
  1378. Xsopen(n)
  1379. Xchar *n;
  1380. X{
  1381. X    FILE *fp;
  1382. X
  1383. X    show_line;
  1384. X    if (!(fp = malloc(sizeof(FILE))))
  1385. X    leave(12,memory);
  1386. X    if (n == NULL) {
  1387. X    if (helplen == -1)
  1388. X        helplen = strlen(helpstr);
  1389. X    fp->des = 0;
  1390. X    fp->bufflen = helplen;
  1391. X    fp->buff = helpstr;
  1392. X    } else {
  1393. X    if (!(fp->des = Open(n,MODE_OLDFILE))) {
  1394. X        free(fp);
  1395. X        return NULL;
  1396. X    }
  1397. X    if (!(fp->buff = malloc(FILEBUFF)))
  1398. X        leave(12,memory);
  1399. X    fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1400. X    }
  1401. X    fp->filepos = 0;
  1402. X    fp->pos = 0;
  1403. X    fp->unget = 0x100;
  1404. X    return fp;
  1405. X}
  1406. X
  1407. Xvoid
  1408. Xsclose(fp)
  1409. XFILE *fp;
  1410. X{
  1411. X    show_line;
  1412. X    if (fp->des) {
  1413. X    Close(fp->des);
  1414. X    free(fp->buff);
  1415. X    }
  1416. X    free(fp);
  1417. X}
  1418. X
  1419. Xchar
  1420. Xsgetc(fp)
  1421. XFILE *fp;
  1422. X{
  1423. X    show_line;
  1424. X    if (fp->unget != 0x100) {
  1425. X    char c;
  1426. X    c = fp->unget;
  1427. X    fp->unget = 0x100;
  1428. X    fp->pos++;
  1429. X    return c;
  1430. X    }
  1431. X
  1432. X    if (fp->pos >= fp->bufflen) {
  1433. X    fp->filepos += fp->bufflen;
  1434. X    fp->bufflen = fp->des ? Read(fp->des,fp->buff,FILEBUFF) : 0;
  1435. X    if (seof(fp))
  1436. X        return 0;
  1437. X    fp->pos = 0;
  1438. X    }
  1439. X    return fp->buff[fp->pos++];
  1440. X}
  1441. X
  1442. Xchar *
  1443. Xsgets(p,n,fp)
  1444. Xchar *p;
  1445. Xint n;
  1446. XFILE *fp;
  1447. X{
  1448. X    char *q = p;
  1449. X
  1450. X    show_line;
  1451. X    sgetcur(fp);
  1452. X    if (seof(fp))
  1453. X    return NULL;
  1454. X    while (q - p < n-1 && (*q++ = getc(fp)) != '\n') {
  1455. X    if (seof(fp)) {
  1456. X        *--q = 0;
  1457. X        return p;
  1458. X    }
  1459. X    }
  1460. X    *q = 0;
  1461. X    return p;
  1462. X};
  1463. X
  1464. X#define START_SIZE  100
  1465. X#define UP_SIZE     20
  1466. X
  1467. Xchar *
  1468. Xsgetline(fp)
  1469. XFILE *fp;
  1470. X{
  1471. X    char *q = malloc(START_SIZE),*p;
  1472. X    int l = START_SIZE;
  1473. X
  1474. X    show_line;
  1475. X    p = q;
  1476. X    sgetcur(fp);
  1477. X    if (seof(fp))
  1478. X    return NULL;
  1479. X    while ((*q++ = getc(fp)) != '\n' && *(q-1) != 12) {
  1480. X    if (seof(fp)) {
  1481. X        *(q-1) = 0;
  1482. X        return p;
  1483. X    }
  1484. X    if (q - p == l) {
  1485. X        if (!(p = realloc(p,l += UP_SIZE)))
  1486. X        leave(12,memory);
  1487. X        q = p + l - UP_SIZE;
  1488. X    }
  1489. X    }
  1490. X    *q = 0;
  1491. X    return p;
  1492. X}
  1493. X
  1494. Xchar
  1495. Xsgetcur(fp)
  1496. XFILE *fp;
  1497. X{
  1498. X    show_line;
  1499. X    if (fp->unget != 0x100) {
  1500. X    return fp->unget;
  1501. X    }
  1502. X
  1503. X    if (fp->pos >= fp->bufflen) {
  1504. X    fp->filepos += fp->bufflen;
  1505. X    fp->bufflen = fp->des ? Read(fp->des,fp->buff,FILEBUFF) : 0;
  1506. X    if (seof(fp))
  1507. X        return 0;
  1508. X    fp->pos = 0;
  1509. X    }
  1510. X    return fp->buff[fp->pos];
  1511. X}
  1512. X
  1513. Xvoid
  1514. Xsseek(fp,p,t)
  1515. XFILE *fp;
  1516. Xint p,t;
  1517. X{
  1518. X    show_line;
  1519. X    fp->unget = 0x100;
  1520. X    switch (t) {
  1521. X    case (SEEK_SET) :
  1522. X        if (p >= fp->filepos && p < fp->filepos+fp->bufflen)
  1523. X        fp->pos = p - fp->filepos;
  1524. X        else {
  1525. X        if (!fp->des) {
  1526. X            if (p <= helplen) {
  1527. X            fp->filepos = 0;
  1528. X            fp->bufflen = helplen;
  1529. X            fp->pos = p;
  1530. X            } else
  1531. X            fp->bufflen = 0;
  1532. X        } else {
  1533. X            fp->filepos = p;
  1534. X            fp->pos = 0;
  1535. X            if (Seek(fp->des,p,OFFSET_BEGINNING) == -1)
  1536. X            fp->bufflen = 0;
  1537. X            else
  1538. X            fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1539. X        }
  1540. X        }
  1541. X        break;
  1542. X    case (SEEK_CUR) :
  1543. X        if ((p < 0 && fp->pos >= -p) ||
  1544. X                     (p >= 0 && p + fp->pos < fp->bufflen))
  1545. X        fp->pos += p;
  1546. X        else {
  1547. X        if (!fp->des) {
  1548. X            if (p + fp->pos <= helplen) {
  1549. X            fp->filepos = 0;
  1550. X            fp->bufflen = helplen;
  1551. X            fp->pos += p;
  1552. X            } else
  1553. X            fp->bufflen = 0;
  1554. X        } else {
  1555. X            if (p < 0)
  1556. X            sseekbot(fp,fp->filepos + fp->pos + p);
  1557. X            else {
  1558. X            fp->filepos += fp->pos + p;
  1559. X            if (Seek(fp->des,fp->filepos,OFFSET_BEGINNING) == -1)
  1560. X                fp->bufflen = 0;
  1561. X            else
  1562. X                fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1563. X            fp->pos = 0;
  1564. X            }
  1565. X        }
  1566. X        }
  1567. X        break;
  1568. X    case (SEEK_END) :
  1569. X        if (!fp->des) {
  1570. X        if (p >= 0 && -p <= helplen) {
  1571. X            fp->filepos = 0;
  1572. X            fp->bufflen = helplen;
  1573. X            fp->pos = helplen+p;
  1574. X        } else
  1575. X            fp->bufflen = 0;
  1576. X        } else {
  1577. X        Seek(fp->des,p,OFFSET_END);
  1578. X        fp->filepos = Seek(fp->des,0,OFFSET_CURRENT);
  1579. X        fp->pos = 0;
  1580. X        fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1581. X        }
  1582. X        break;
  1583. X    }
  1584. X}
  1585. X
  1586. Xvoid
  1587. Xsseekbot(fp,p)
  1588. XFILE *fp;
  1589. Xint p;
  1590. X{
  1591. X    show_line;
  1592. X    if (p >= fp->filepos && p <= fp->filepos+fp->bufflen)
  1593. X    fp->pos = p - fp->filepos;
  1594. X    else {
  1595. X    if (!fp->des)
  1596. X        sseek(fp,p,SEEK_SET);
  1597. X    else {
  1598. X        fp->filepos = p - FILEBUFF + 1;
  1599. X        if (fp->filepos < 0)
  1600. X        fp->filepos = 0;
  1601. X        if (Seek(fp->des,fp->filepos,OFFSET_BEGINNING) == -1)
  1602. X        fp->bufflen = 0;
  1603. X        else
  1604. X        fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
  1605. X        fp->pos = p - fp->filepos;
  1606. X    }
  1607. X    }
  1608. X}
  1609. X
  1610. Xvoid
  1611. Xsputs(p)
  1612. Xchar *p;
  1613. X{
  1614. X    chkabort();
  1615. X    Write(Output(),p,strlen(p));
  1616. X}
  1617. X
  1618. X#ifdef __DEBUG__
  1619. X
  1620. XPrototype void putint(int);
  1621. X
  1622. Xvoid
  1623. Xputint(i)
  1624. Xint i;
  1625. X{
  1626. X    int m = 1000000,f = FALSE;
  1627. X    char buf[9],*p = buf;
  1628. X
  1629. X    for ( ; m ; m /= 10) {
  1630. X    if (f || i >= m || m == 1) {
  1631. X        *p++ = (i / m + '0');
  1632. X        f = TRUE;
  1633. X        i %= m;
  1634. X    }
  1635. X    }
  1636. X    *p = 0;
  1637. X    sputs(buf);
  1638. X}
  1639. X
  1640. XPrototype void putchar(char);
  1641. X
  1642. Xvoid
  1643. Xputchar(c)
  1644. Xchar c;
  1645. X{
  1646. X    Write(Output(),&c,1);
  1647. X}
  1648. X
  1649. X#ifdef __TRACE__
  1650. X
  1651. XPrototype void reportline(char *, int);
  1652. X
  1653. Xvoid
  1654. Xreportline(name,line)
  1655. Xchar *name;
  1656. Xint line;
  1657. X{
  1658. X    sputs("Passing by file ");
  1659. X    sputs(name);
  1660. X    sputs(" line ");
  1661. X    putint(line);
  1662. X    putchar('\n');
  1663. X}
  1664. X
  1665. X#endif (__TRACE__)
  1666. X
  1667. X#endif (__DEBUG__)
  1668. END_OF_FILE
  1669. if test 5265 -ne `wc -c <'src/sless_file.c'`; then
  1670.     echo shar: \"'src/sless_file.c'\" unpacked with wrong size!
  1671. fi
  1672. # end of 'src/sless_file.c'
  1673. fi
  1674. if test -f 'src/sless_help.h' -a "${1}" != "-c" ; then 
  1675.   echo shar: Will not clobber existing file \"'src/sless_help.h'\"
  1676. else
  1677. echo shar: Extracting \"'src/sless_help.h'\" \(1056 characters\)
  1678. sed "s/^X//" >'src/sless_help.h' <<'END_OF_FILE'
  1679. X
  1680. Xint helplen = -1;
  1681. X
  1682. Xconst char helpstr[] =
  1683. X"\n"\
  1684. X"                          Sless V"\
  1685. XVERSION\
  1686. X"\n"\
  1687. X"                        by Jon Spencer\n"\
  1688. X"\n"\
  1689. X"     <space>...............Advance text one page.\n"\
  1690. X"     <backspace> or 'b'....Move back one page.\n"\
  1691. X"     'd'...................Move down half of a page.\n"\
  1692. X"     'u'...................Move up half of a page.\n"\
  1693. X"     <return> or\n"\
  1694. X"      <down arrow>.........Move down one line.\n"\
  1695. X"     <up arrow>............Move up one line.\n"\
  1696. X"     '<' or\n"\
  1697. X"      <shift><up arrow>....Move to the top of the file.\n"\
  1698. X"     '>' or\n"\
  1699. X"      <shift><down arrow>..Move to the bottom of the file.\n"\
  1700. X"     '/'...................Search forward for a pattern.\n"\
  1701. X"     ';'...................Search backward for a pattern.\n"\
  1702. X"     'n'...................Search for next occurance of last pattern.\n"\
  1703. X"     'p'...................Search for previous occurance of last pattern.\n"\
  1704. X"     '?' or 'h' or <help>..This help page.\n"\
  1705. X"     'q'...................quit (press this to return to the file.)\n"
  1706. X;
  1707. END_OF_FILE
  1708. if test 1056 -ne `wc -c <'src/sless_help.h'`; then
  1709.     echo shar: \"'src/sless_help.h'\" unpacked with wrong size!
  1710. fi
  1711. # end of 'src/sless_help.h'
  1712. fi
  1713. if test -f 'src/sless_win.c' -a "${1}" != "-c" ; then 
  1714.   echo shar: Will not clobber existing file \"'src/sless_win.c'\"
  1715. else
  1716. echo shar: Extracting \"'src/sless_win.c'\" \(6660 characters\)
  1717. sed "s/^X//" >'src/sless_win.c' <<'END_OF_FILE'
  1718. X
  1719. X#include <sless_defs.h>
  1720. X#include <string.h>
  1721. X#include <stdlib.h>
  1722. X#include <ctype.h>
  1723. X#include <libraries/dosextens.h>
  1724. X#include <intuition/intuition.h>
  1725. X#include <clib/dos_protos.h>
  1726. X#include <clib/intuition_protos.h>
  1727. X#include <clib/exec_protos.h>
  1728. X
  1729. XPrototype BPTR            makeoutput(char *);
  1730. XPrototype void            closeoutput(BPTR);
  1731. XPrototype LONG            stdpkt(LONG, LONG, BPTR);
  1732. XPrototype void            setupcon(BPTR);
  1733. XPrototype void            putconstr(char *, BPTR);
  1734. XPrototype void            putconchar(char, BPTR);
  1735. XPrototype short         getconchar(BPTR);
  1736. XPrototype char            rawreadcon(BPTR);
  1737. XPrototype struct conreport *    getconreport(short, BPTR);
  1738. XPrototype struct conreport *    readconreport(BPTR);
  1739. XPrototype void            windowresized(BPTR);
  1740. XPrototype char *        getstr(BPTR);
  1741. XPrototype void            findsize(int *, int *, BPTR);
  1742. XPrototype void            sto_char(short);
  1743. XPrototype short         get_sto(void);
  1744. XPrototype void            putconint(int, BPTR);
  1745. X
  1746. Xextern const char memory[];
  1747. Xstatic char *oldname;
  1748. X
  1749. Xextern int sx,sy;
  1750. Xextern char seek;
  1751. X
  1752. XBPTR
  1753. Xmakeoutput(n)
  1754. Xchar *n;
  1755. X{
  1756. X    BPTR con;
  1757. X    struct MsgPort *cport;
  1758. X    __aligned struct InfoData id;
  1759. X    struct Window *win;
  1760. X    char buff[77];
  1761. X
  1762. X    show_line;
  1763. X    if (!IsInteractive(con = Output())) {
  1764. X    strcpy(buff,"con:0/1/640/199/");
  1765. X    strncat(buff,n,60);
  1766. X    if (!(con = Open(buff,MODE_NEWFILE)))
  1767. X        leave(15,"sless: Unable to obtain a display.\n");
  1768. X    } else {
  1769. X    stdpkt(ACTION_DISK_INFO,(LONG)(&id >> 2),con);
  1770. X    win = (struct Window *)(id.id_VolumeNode);
  1771. X    oldname = win->Title;
  1772. X    SetWindowTitles(win,n,(char *)-1);
  1773. X    }
  1774. X    setupcon(con);
  1775. X    return con;
  1776. X}
  1777. X
  1778. Xvoid
  1779. Xcloseoutput(con)
  1780. XBPTR con;
  1781. X{
  1782. X    struct MsgPort *cport;
  1783. X    __aligned struct InfoData id;
  1784. X    struct Window *win;
  1785. X
  1786. X    show_line;
  1787. X    if (con != Output()) {
  1788. X    Close(con);
  1789. X    return;
  1790. X    }
  1791. X
  1792. X    stdpkt(ACTION_DISK_INFO,(LONG)(&id >> 2),con);
  1793. X    win = (struct Window *)(id.id_VolumeNode);
  1794. X    SetWindowTitles(win,oldname,(char *)-1);
  1795. X    stdpkt(ACTION_SCREEN_MODE,0,con);
  1796. X    putconstr("\x9b p",con);
  1797. X}
  1798. X
  1799. XLONG
  1800. Xstdpkt(type,arg,con)
  1801. XLONG type,arg;
  1802. XBPTR con;
  1803. X{
  1804. X    __aligned struct StandardPacket pkt;
  1805. X    struct MsgPort *reply,*who;
  1806. X
  1807. X    show_line;
  1808. X    who = ((struct FileHandle *)(con << 2))->fh_Type;
  1809. X
  1810. X    if (!(reply = CreatePort(NULL,0)))
  1811. X    leave(15,"sless: Unable to send packet");
  1812. X
  1813. X    pkt.sp_Msg.mn_Node.ln_Name = (char *)&(pkt.sp_Pkt);
  1814. X    pkt.sp_Pkt.dp_Link = &(pkt.sp_Msg);
  1815. X    pkt.sp_Pkt.dp_Port = reply;
  1816. X    pkt.sp_Pkt.dp_Type = type;
  1817. X    pkt.sp_Pkt.dp_Arg1 = arg;
  1818. X    PutMsg(who,&(pkt.sp_Msg));
  1819. X    WaitPort(reply);
  1820. X    GetMsg(reply);
  1821. X
  1822. X    DeletePort(reply);
  1823. X
  1824. X    return pkt.sp_Pkt.dp_Res1;
  1825. X}
  1826. X
  1827. Xvoid
  1828. Xsetupcon(con)
  1829. XBPTR con;
  1830. X{
  1831. X    show_line;
  1832. X    stdpkt(ACTION_SCREEN_MODE,-1,con);
  1833. X    putconstr("\x9B20h\x9b12{",con);
  1834. X}
  1835. X
  1836. Xstruct conreport *
  1837. Xgetconreport(e,con)
  1838. Xshort e;
  1839. XBPTR con;
  1840. X{
  1841. X    char p;
  1842. X    struct conreport *cr;
  1843. X
  1844. X    show_line;
  1845. X    do {
  1846. X    while ((p = rawreadcon(con)) != (char)0x9B)
  1847. X        sto_char(p);
  1848. X
  1849. X    if (cr = readconreport(con)) {
  1850. X        if (cr->conid == e)
  1851. X        return cr;
  1852. X        else {
  1853. X        sto_char(cr->conid);
  1854. X        free(cr);
  1855. X        }
  1856. X    }
  1857. X    } while (TRUE);
  1858. X}
  1859. X
  1860. Xstruct conreport *
  1861. Xreadconreport(con)
  1862. XBPTR con;
  1863. X{
  1864. X    struct conreport *cr;
  1865. X    char p;
  1866. X    int i=0,v;
  1867. X
  1868. X    show_line;
  1869. X    if (!(cr = malloc(sizeof(struct conreport))))
  1870. X    leave(12,memory);
  1871. X
  1872. X    do {
  1873. X    v = 0;
  1874. X    p = rawreadcon(con);
  1875. X    while (isdigit(p)) {
  1876. X        v = v * 10 + p - '0';
  1877. X        p = rawreadcon(con);
  1878. X    }
  1879. X    cr->args[i++] = v;
  1880. X    } while (p == ';');
  1881. X    v = makeconid(p,0);
  1882. X    if (p == '?' || p == ' ') {
  1883. X    p = rawreadcon(con);
  1884. X    v = v + p;
  1885. X    }
  1886. X    cr->conid = v;
  1887. X    if (v == makeconid('|',0) && cr->args[0] == 12) {
  1888. X    windowresized(con);
  1889. X    return NULL;
  1890. X    }
  1891. X    return cr;
  1892. X}
  1893. X
  1894. Xshort
  1895. Xgetconchar(con)
  1896. XBPTR con;
  1897. X{
  1898. X    short p;
  1899. X    struct conreport *cr;
  1900. X
  1901. X    show_line;
  1902. X    do {
  1903. X    if (p = get_sto())
  1904. X        break;
  1905. X    if ((p = rawreadcon(con)) == (char)'\x9b') {
  1906. X        if (cr = readconreport(con)) {
  1907. X        p = cr->conid;
  1908. X        free(cr);
  1909. X        break;
  1910. X        }
  1911. X    } else
  1912. X        break;
  1913. X    } while (TRUE);
  1914. X    return p;
  1915. X}
  1916. X
  1917. Xchar
  1918. Xrawreadcon(con)
  1919. XBPTR con;
  1920. X{
  1921. X    char p;
  1922. X
  1923. X    show_line;
  1924. X    while (!WaitForChar(con,100000)) {
  1925. X    chkabort();
  1926. X    }
  1927. X    if (Read(con,&p,1) != 1)
  1928. X    return 0;
  1929. X    return p;
  1930. X}
  1931. X
  1932. Xvoid
  1933. Xputconchar(c,con)
  1934. Xchar c;
  1935. XBPTR con;
  1936. X{
  1937. X    show_line;
  1938. X    Write(con,&c,1);
  1939. X    chkabort();
  1940. X}
  1941. X
  1942. Xvoid
  1943. Xputconstr(p,con)
  1944. Xchar *p;
  1945. XBPTR con;
  1946. X{
  1947. X    show_line;
  1948. X    Write(con,p,strlen(p));
  1949. X    chkabort();
  1950. X}
  1951. X
  1952. Xvoid windowresized(con)
  1953. XBPTR con;
  1954. X{
  1955. X    show_line;
  1956. X    findsize(&sx,&sy,con);
  1957. X    if (seek)
  1958. X    refreshscreen();
  1959. X    else {
  1960. X    bottomline();
  1961. X    putconstr(": ",con);
  1962. X    }
  1963. X}
  1964. X
  1965. Xchar *
  1966. Xgetstr(con)
  1967. XBPTR con;
  1968. X{
  1969. X    short c;
  1970. X    char buff[200],*p = buff,*q;
  1971. X
  1972. X    show_line;
  1973. X    *p = 0;
  1974. X    do {
  1975. X    switch(c = getconchar(con)) {
  1976. X        case (13) :
  1977. X        goto end;
  1978. X        case (makeconid('D',0)) :
  1979. X        if (p != buff) {
  1980. X            putconstr("\x9bD",con);
  1981. X            p--;
  1982. X        }
  1983. X        break;
  1984. X        case (makeconid('C',0)) :
  1985. X        if (*p) {
  1986. X            putconstr("\x9bC",con);
  1987. X            p++;
  1988. X        }
  1989. X        break;
  1990. X        case (makeconid(' ','A')) :
  1991. X        if (p != buff) {
  1992. X            putconchar('\x9b',con);
  1993. X            putconint(p-buff,con);
  1994. X            putconchar('D',con);
  1995. X            p = buff;
  1996. X        }
  1997. X        break;
  1998. X        case (makeconid(' ','@')) :
  1999. X        if (*p) {
  2000. X            putconchar('\x9b',con);
  2001. X            putconint(strlen(p),con);
  2002. X            putconchar('C',con);
  2003. X            p += strlen(p);
  2004. X        }
  2005. X        break;
  2006. X        case (8) :
  2007. X        if (p != buff) {
  2008. X            putconstr("\x9bD\x9bP",con);
  2009. X            q = --p;
  2010. X            while (*q = *(q+1))
  2011. X            q++;
  2012. X        }
  2013. X        break;
  2014. X        case (127) :
  2015. X        if (*p) {
  2016. X            putconstr("\x9bP",con);
  2017. X            q = p;
  2018. X            while (*q = *(q+1))
  2019. X            q++;
  2020. X        }
  2021. X        default :
  2022. X        if (isprint(c)) {
  2023. X            putconstr("\x9b@",con);
  2024. X            putconchar(c,con);
  2025. X            q = p + strlen(p) + 1;
  2026. X            do {
  2027. X            *q = *(q-1);
  2028. X            q--;
  2029. X            } while (q != p);
  2030. X            *p++ = c;
  2031. X        }
  2032. X    }
  2033. X    } while (TRUE);
  2034. X
  2035. Xend:
  2036. X    if (strlen(buff) == 0)
  2037. X    return NULL;
  2038. X    if (!(p = malloc(strlen(buff)+1)))
  2039. X    leave(12,memory);
  2040. X    strcpy(p,buff);
  2041. X    return p;
  2042. X}
  2043. X
  2044. Xvoid
  2045. Xputconint(x,con)
  2046. Xint x;
  2047. XBPTR con;
  2048. X{
  2049. X    int v;
  2050. X    char p,f = FALSE;
  2051. X
  2052. X    show_line;
  2053. X    for (v = 1000000; v > 0; v /= 10) {
  2054. X    p = x / v;
  2055. X    x = x - p*v;
  2056. X    if (p != 0 || f) {
  2057. X        f = TRUE;
  2058. X        putconchar(p + '0',con);
  2059. X    }
  2060. X    }
  2061. X}
  2062. X
  2063. Xvoid
  2064. Xfindsize(x,y,con)
  2065. Xint *x,*y;
  2066. XBPTR con;
  2067. X{
  2068. X    struct conreport *cr;
  2069. X
  2070. X    show_line;
  2071. X    putconstr("\x9b0 q",con);
  2072. X
  2073. X    cr = getconreport(makeconid(' ','r'),con);
  2074. X
  2075. X    *x = cr->args[3];
  2076. X    *y = cr->args[2];
  2077. X    free(cr);
  2078. X}
  2079. X
  2080. X#define STO_LEN     100
  2081. Xstatic short sto_buff[STO_LEN];
  2082. Xstatic int sto_s = 0,sto_e = 0;
  2083. X
  2084. Xvoid
  2085. Xsto_char(e)
  2086. Xshort e;
  2087. X{
  2088. X    show_line;
  2089. X    sto_buff[sto_e] = e;
  2090. X    sto_e = (sto_e + 1) % STO_LEN;
  2091. X    if (sto_e == sto_s)             /* lost some off the end */
  2092. X    sto_s = (sto_s + 1) % STO_LEN;
  2093. X}
  2094. X
  2095. Xshort
  2096. Xget_sto()
  2097. X{
  2098. X    short c;
  2099. X
  2100. X    show_line;
  2101. X    if (sto_s == sto_e)
  2102. X    return 0;
  2103. X    c = sto_buff[sto_s];
  2104. X    sto_s = (sto_s + 1) % STO_LEN;
  2105. X    return c;
  2106. X}
  2107. X
  2108. END_OF_FILE
  2109. if test 6660 -ne `wc -c <'src/sless_win.c'`; then
  2110.     echo shar: \"'src/sless_win.c'\" unpacked with wrong size!
  2111. fi
  2112. # end of 'src/sless_win.c'
  2113. fi
  2114. if test -f 'src/sman.c' -a "${1}" != "-c" ; then 
  2115.   echo shar: Will not clobber existing file \"'src/sman.c'\"
  2116. else
  2117. echo shar: Extracting \"'src/sman.c'\" \(6384 characters\)
  2118. sed "s/^X//" >'src/sman.c' <<'END_OF_FILE'
  2119. X
  2120. X#include <stdlib.h>
  2121. X#include <stdio.h>
  2122. X#include <string.h>
  2123. X#include <ctype.h>
  2124. X#include <stdarg.h>
  2125. X#include <libraries/dos.h>
  2126. X#include <clib/dos_protos.h>
  2127. X#include <clib/exec_protos.h>
  2128. X#include <clib/sregexp_protos.h>
  2129. X#include <libraries/sregexpbase.h>
  2130. X#include "sman_defs.h"
  2131. X
  2132. XPrototype long        findman(char *, char *, char *, int);
  2133. XPrototype long        searchpath(char *, char *, char *, int);
  2134. XPrototype void        usage(void);
  2135. XPrototype long        okfile(char *, char *, char);
  2136. XPrototype void        putline(char *);
  2137. XPrototype void        leave(char *, int);
  2138. XPrototype char *    expandpath(char *, char *);
  2139. XPrototype int        spathbrk(void);
  2140. X
  2141. Xconst char memory[] = "sman: Unable to allocate memory.\n";
  2142. X
  2143. Xint
  2144. Xmain(ac,av)
  2145. Xint ac;
  2146. Xchar *av[];
  2147. X{
  2148. X    char *com,*path = NULL,file[MAXPATH],*viewer = NULL;
  2149. X    long line;
  2150. X
  2151. X    do {
  2152. X    if (--ac < 1 || **++av != '-')
  2153. X        break;
  2154. X    switch (*(*av+1)) {
  2155. X        case ('p') :
  2156. X        case ('P') :
  2157. X        if (!*(path = *av + 2)) {
  2158. X            ac--;
  2159. X            path = *(++av);
  2160. X        }
  2161. X        break;
  2162. X        case ('v') :
  2163. X        case ('V') :
  2164. X        if (!*(viewer = *av + 2)) {
  2165. X            ac--;
  2166. X            viewer = *(++av);
  2167. X        }
  2168. X        break;
  2169. X        default :
  2170. X        usage();
  2171. X    }
  2172. X    } while (1);
  2173. X    if (ac < 1)
  2174. X    usage();
  2175. X
  2176. X    if (!path)
  2177. X    if (!(path = getenv("SmanPath"))) {
  2178. X        putline("Environment Variable SmanPath not defined.\n");
  2179. X        return 1;
  2180. X    }
  2181. X    if (!viewer)
  2182. X    viewer = getenv("SmanViewer");
  2183. X
  2184. X    while (ac >= 1) {
  2185. X    if ((line = findman(av[0],path,file,MAXPATH)) != NOT_FOUND) {
  2186. X        if (viewer) {
  2187. X        if (!(com = malloc(strlen(viewer)+strlen(file)+2))) {
  2188. X            putline(memory);
  2189. X            return 5;
  2190. X        }
  2191. X        strcpy(com,viewer);
  2192. X        strcat(com," ");
  2193. X        strcat(com,file);
  2194. X        } else {
  2195. X        char f = FALSE;
  2196. X        int i,mod;
  2197. X
  2198. X        if (!(com = malloc(strlen(file)+17))) {
  2199. X            putline(memory);
  2200. X            return 5;
  2201. X        }
  2202. X        strcpy(com,"sless -");
  2203. X        if (line > 0)
  2204. X            com[7] = 'l';
  2205. X        else {
  2206. X            com[7] = 'c';
  2207. X            line = -line;
  2208. X        }
  2209. X        for (i = 8, mod = 10000000; mod != 0; mod /= 10) {
  2210. X            com[i] = line / mod + '0';
  2211. X            if (com[i] != '0' || f || mod == 1) {
  2212. X            f = TRUE;
  2213. X            i++;
  2214. X            }
  2215. X            line %= mod;
  2216. X        }
  2217. X        com[i++] = ' ';
  2218. X        strcpy(com+i,file);
  2219. X        }
  2220. X        system(com);
  2221. X    }
  2222. X    ac--;
  2223. X    av++;
  2224. X    }
  2225. X
  2226. X    return 0;
  2227. X}
  2228. X
  2229. Xlong
  2230. Xfindman(tar,p,file,len)
  2231. Xchar *tar,*p,*file;
  2232. Xint len;
  2233. X{
  2234. X    char *h,q;
  2235. X    long line;
  2236. X
  2237. X    do {
  2238. X    h = p;
  2239. X    while (*p != ';' && *p) p++;
  2240. X    q = *p;
  2241. X    *p = 0;
  2242. X    line = searchpath(h,tar,file,len);
  2243. X    *p++ = q;
  2244. X    if (line != NOT_FOUND)
  2245. X        return line;
  2246. X    } while (q);
  2247. X
  2248. X    putline("No manual entry found for '");
  2249. X    putline(tar);
  2250. X    putline("'.\n");
  2251. X    return NOT_FOUND;
  2252. X}
  2253. X
  2254. X/* This has to be global to free it on a break... */
  2255. Xstruct SpathInfo *spath = NULL;
  2256. X
  2257. Xlong
  2258. Xsearchpath(p,tar,file,len)
  2259. Xchar *p,*tar,*file;
  2260. Xint len;
  2261. X{
  2262. X    char *e;
  2263. X    long line,test;
  2264. X
  2265. X    if (!(e = expandpath(p + (*p == ADOC || *p == DREF ? 1 : 0),tar)))
  2266. X    return NOT_FOUND;
  2267. X
  2268. X    spath = AnchorPath("",e);
  2269. X    onbreak(&spathbrk);
  2270. X    free(e);
  2271. X    if (!spath)
  2272. X    return NOT_FOUND;
  2273. X
  2274. X    line = NOT_FOUND;
  2275. X    do {
  2276. X    while ((test = NextFile(spath,file,len,SP_FILES_ONLY)) > 0) {
  2277. X        line = okfile(file,tar,*p);
  2278. X        if (line != NOT_FOUND)
  2279. X        break;
  2280. X    }
  2281. X    if (test == SPE_SIGBREAK) {
  2282. X        chkabort();
  2283. X        SetSignal(0,SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F);
  2284. X        test = 0;
  2285. X    }
  2286. X    } while (test >= 0);
  2287. X    onbreak(NULL);
  2288. X    FreeSpathInfo(spath);
  2289. X    spath = NULL;
  2290. X    return line;
  2291. X}
  2292. X
  2293. Xint
  2294. Xspathbrk()
  2295. X{
  2296. X    if (spath)
  2297. X    FreeSpathInfo(spath);
  2298. X    return 1;
  2299. X}
  2300. X
  2301. Xlong
  2302. Xokfile(file,tar,ftype)
  2303. Xchar *file,*tar,ftype;
  2304. X{
  2305. X    FILE *fp;
  2306. X    char buff[200],*m,*n;
  2307. X    int line,len;
  2308. X    struct SregExp *spat;
  2309. X
  2310. X    if (ftype != ADOC && ftype != DREF)
  2311. X    return 0;
  2312. X
  2313. X    if (!(fp = fopen(file,"r")))
  2314. X    return NOT_FOUND;
  2315. X
  2316. X    if (ftype == ADOC) {
  2317. X    line = -1;
  2318. X    do {
  2319. X        if (fgets(buff,199,fp) != buff) {
  2320. X        fclose(fp);
  2321. X        return NOT_FOUND;
  2322. X        }
  2323. X        line++;
  2324. X    } while (*buff == '\n');
  2325. X
  2326. X    if (strnicmp("TABLE OF CONTENTS",buff,17)) {
  2327. X        fclose(fp);
  2328. X        return NOT_FOUND;
  2329. X    }
  2330. X
  2331. X    strcpy(buff,"#?/&\n");
  2332. X    if (!(spat = ParseSregExp(buff))) {
  2333. X        fclose(fp);
  2334. X        return NOT_FOUND;
  2335. X    }
  2336. X    line = 0;
  2337. X    while (fgets(buff,199,fp) == buff) {
  2338. X        line++;
  2339. X        if (*buff == 12) {
  2340. X        FreeSregExp(spat);
  2341. X        fclose(fp);
  2342. X        return NOT_FOUND;
  2343. X        }
  2344. X        if (MatchSregExp(buff,spat,TRUE))
  2345. X        goto agotit;
  2346. X    }
  2347. X    FreeSregExp(spat);
  2348. X    fclose(fp);
  2349. X    return NOT_FOUND;
  2350. X
  2351. X    agotit:
  2352. X    FreeSregExp(spat);
  2353. X    len = strlen(buff);
  2354. X    buff[len-1] = 0;
  2355. X    if (!(m = malloc(len))) {
  2356. X        fclose(fp);
  2357. X        leave(memory,5);
  2358. X    }
  2359. X    strcpy(m,buff);
  2360. X    while (fgets(buff,199,fp) == buff) {
  2361. X        line++;
  2362. X        if (strncmp(m,buff,len - 1) == 0) {
  2363. X        free(m);
  2364. X        fclose(fp);
  2365. X        return line;
  2366. X        }
  2367. X    }
  2368. X    free(m);
  2369. X    fclose(fp);
  2370. X    return NOT_FOUND;
  2371. X    } else {
  2372. X    len = strlen(tar);
  2373. X    while (fgets(buff,199,fp) == buff) {
  2374. X        if (strncmp(tar,buff,len) == 0 && isspace(buff[len])) {
  2375. X        fclose(fp);
  2376. X        goto dgotit;
  2377. X        }
  2378. X    }
  2379. X    fclose(fp);
  2380. X    return NOT_FOUND;
  2381. X
  2382. X    dgotit:
  2383. X    m = buff;
  2384. X    for (len = 0; len < 2; len++) {
  2385. X        while (!isspace(*m++)) ;
  2386. X        while (isspace(*m)) m++;
  2387. X    }
  2388. X    n = m;
  2389. X    while (*n != ':' && *n != '/' && !isspace(*n)) n++;
  2390. X    if (*n == ':')
  2391. X        n = file;
  2392. X    else {
  2393. X        n = file + strlen(file);
  2394. X        while (*(n-1) != '/' && *(n-1) != ':' && n != file) n--;
  2395. X    }
  2396. X    while (!isspace(*m))
  2397. X        *n++ = *m++;
  2398. X    *n = 0;
  2399. X    while (isspace(*m)) m++;
  2400. X    if (*m++ != '@' || *m++ != '@')
  2401. X        return 0;
  2402. X    line = 0;
  2403. X    while (!isspace(*m))
  2404. X        line = line*10 - *m++ + '0';
  2405. X    return line;
  2406. X    }
  2407. X}
  2408. X
  2409. Xchar *
  2410. Xexpandpath(p,tar)
  2411. Xchar *p,*tar;
  2412. X{
  2413. X    int num = 0;
  2414. X    char *q,*r,*t;
  2415. X
  2416. X    for (q = p; *q; q++) {
  2417. X    if (*q == '\'' && *(q+1) == '&')
  2418. X        q++;
  2419. X    else if (*q == '&')
  2420. X        num++;
  2421. X    }
  2422. X
  2423. X    if (!(q = malloc(strlen(p) + num*(strlen(tar)+1) + 1))) {
  2424. X    putline(memory);
  2425. X    return NULL;
  2426. X    }
  2427. X
  2428. X    for (r = q; *p; p++) {
  2429. X    if (*p == '&') {
  2430. X        *r++ = '(';
  2431. X        for (t = tar; *t; t++)
  2432. X        *r++ = *t;
  2433. X        *r++ = ')';
  2434. X    } else {
  2435. X        if (*p == '\'' && *(p+1) == '&')
  2436. X        p++;
  2437. X        *r++ = *p;
  2438. X    }
  2439. X    }
  2440. X    *r = 0;
  2441. X    return q;
  2442. X}
  2443. X
  2444. Xvoid
  2445. Xusage()
  2446. X{
  2447. X    putline("sman V"\
  2448. X         VERSION\
  2449. X         ", "
  2450. X         __DATE__\
  2451. X         ", (c)Copyright 1991 by Jon Spencer.\n");
  2452. X    putline("Usage: Sman [-pSearch pattern] [-vViewer] target [target...]\n");
  2453. X    exit(2);
  2454. X}
  2455. X
  2456. Xvoid
  2457. Xputline(p)
  2458. Xchar *p;
  2459. X{
  2460. X    Write(Output(),p,strlen(p));
  2461. X}
  2462. X
  2463. Xvoid
  2464. Xleave(p,x)
  2465. Xchar *p;
  2466. Xint x;
  2467. X{
  2468. X    putline(p);
  2469. X    exit(x);
  2470. X}
  2471. X
  2472. X/*
  2473. Xint printf(f, ...)
  2474. Xconst char *f;
  2475. X{
  2476. X    char buff[100];
  2477. X    va_list va;
  2478. X
  2479. X    va_start(va,f);
  2480. X    vsprintf(buff,f,va);
  2481. X    va_end(va);
  2482. X    Write(Output(),buff,strlen(buff));
  2483. X}
  2484. X*/
  2485. END_OF_FILE
  2486. if test 6384 -ne `wc -c <'src/sman.c'`; then
  2487.     echo shar: \"'src/sman.c'\" unpacked with wrong size!
  2488. fi
  2489. # end of 'src/sman.c'
  2490. fi
  2491. if test -f 'src/sman.n' -a "${1}" != "-c" ; then 
  2492.   echo shar: Will not clobber existing file \"'src/sman.n'\"
  2493. else
  2494. echo shar: Extracting \"'src/sman.n'\" \(3849 characters\)
  2495. sed "s/^X//" >'src/sman.n' <<'END_OF_FILE'
  2496. X.*
  2497. X.*
  2498. X.TH SMAN 1 "AMIGA Programmer's Manual" "Jon Spencer" "Version 1.0"
  2499. X.SH NAME
  2500. Xsman - a document lookup program.
  2501. X.SH SYNOPSIS
  2502. X.bo "sman
  2503. X[-p Search Pattern] [-v Viewer] target [target...]
  2504. X.SH DESCRIPTION
  2505. XThere is no uniform standard for the format or position of documentation
  2506. Xfiles on the Amiga.  This makes a manual program in the style of the Unix
  2507. X.ul "man
  2508. Xprogram a somewhat difficult thing to create.
  2509. X.ul "sman
  2510. Xattempts to overcome this difficulty by allowing the user to
  2511. Xspecify quite general rules for the location of documentation
  2512. Xfiles. Once a document is located, it is passed on to a text viewer
  2513. Xto be displayed.
  2514. X
  2515. XThere are two ways the documentation lookup rules can be passed to
  2516. X.ul "sman.
  2517. XThe first is by the use of the
  2518. X.bo "-p
  2519. Xcommand line argument, the second is by the ENV: environment
  2520. Xvariable
  2521. X.bo "SmanPath.
  2522. XThe command line argument will override any definition of the
  2523. Xenvironment variable, but at least one must be defined.
  2524. X
  2525. XThe format of the lookup rule is:
  2526. X
  2527. X.in +5
  2528. Xrule1;rule2;...
  2529. X.in -5
  2530. X
  2531. XEach of the rules will be searched in order until a match is found.
  2532. XA rule is formed by an optional special character, which specifies
  2533. Xthe kind of search to be performed on the matching files, followed
  2534. Xby a (possibly) wildcarded AmigaDOS path specifying the
  2535. Xfiles to be searched.  See
  2536. X.ul "sreg.doc
  2537. Xfor a discussion of the wildcard format.
  2538. X
  2539. XThere are currently three kinds of search rules implemented:
  2540. X
  2541. X.ta
  2542. X.in +4;.ta +0
  2543. X.de opt
  2544. X.ti -3;.bo "$0
  2545. X.en
  2546. X.opt Default
  2547. X@t If the rule does not start with one of the characters discussed
  2548. Xbelow, then no special search is done on the files on the path, and
  2549. X.ul "sman
  2550. Xwill succeed on the first file found.  There is a special wildcard character
  2551. Xdefined in sman to make this useful.  If the character '&' is found
  2552. Xin the search path, it will be expanded to the current target.
  2553. XFor example, if you typed 'sman test' and
  2554. X.bo "SmanPath
  2555. Xwas defined as 'DOCS:.../&.(doc|man)', then the path sman
  2556. Xwould try to match would be 'DOCS:.../(test).(doc|man)'.
  2557. X
  2558. X.opt @@
  2559. X@tIf this is the first character of the rule, then sman will assume
  2560. Xthe matched files are
  2561. X.ul "dme.refs
  2562. Xformat files, as used by Matt Dillon's
  2563. X.ul "dme
  2564. Xeditor.  The files will be searched for an entry matching the
  2565. Xtarget.
  2566. X.bp
  2567. X.opt +
  2568. X@tThis type of rule tells
  2569. X.ul "sman
  2570. Xthe matching files are Amiga
  2571. XAutodoc format files.  Each file on the path will be search
  2572. Xfor an entry matching the target.  For example, if
  2573. X.bo "SmanPath
  2574. Xwas '+Autodocs:#?/#?.doc', then 'sman Write' would match to
  2575. X.in +3
  2576. X'Autodocs:LibrariesA-K/dos.doc' (under 1.3 anyway).
  2577. X.in -7
  2578. X
  2579. XAll file name searches are case insensitive. All searches within
  2580. Xa file (for '+' and '@@' type rules) are case sensitive.
  2581. X
  2582. XOnce
  2583. X.ul "sman
  2584. Xhas found a match, that file is passed onto a text viewer for display.
  2585. XThe default viewer is
  2586. X.ul "sless,
  2587. Xbut this can be overridden by either the
  2588. X.bo "-v
  2589. Xcommand line argument
  2590. Xor the environment variable
  2591. X.bo "SmanViewer.
  2592. XIf the default viewer is not overridden, then both '+' and '@@' style
  2593. Xmatches will tell
  2594. X.ul "sless
  2595. Xto start displaying the file at the correct position.
  2596. XIf the default viewer is overridden, then all
  2597. Xfiles will be displayed at the first line.
  2598. X
  2599. X
  2600. X.SH EXAMPLES
  2601. X
  2602. XExample
  2603. X.bo "SmanPath
  2604. Xvariable:
  2605. X.in +4
  2606. X
  2607. X+AutoDocs:#?/#?.doc;@@dcc:doc/dme.refs;@@dcc:man/dme.refs;
  2608. X.br
  2609. XDOCS:.../&(.doc|.man|.txt)
  2610. X.in -4
  2611. X
  2612. X.SH ADDITION CONSIDERATIONS
  2613. X
  2614. X.ul "sman
  2615. Xwill always take the first match that it finds, so the order of the
  2616. Xrules can be used to manipulate the order of the search.
  2617. X
  2618. XAlso, '@@'
  2619. X.ul "dme.refs
  2620. Xstyle searches are the fastest.  If you have the
  2621. X.ul "autorefs
  2622. Xprogram from Matt Dillon's
  2623. X.ul "DICE
  2624. Xpackage, you are better off running this on your Autodocs, rather
  2625. Xthan using the '+' style search.
  2626. X
  2627. X.SH "SEE ALSO"
  2628. Xsless(1)
  2629. X
  2630. X.SH "BUG REPORTS"
  2631. XPlease send bug reports, comments etc. to
  2632. X.in +5
  2633. X
  2634. XJon Spencer
  2635. X
  2636. XEMail: bhgs@@gpu.utcs.utoronto.ca
  2637. X.in-5
  2638. END_OF_FILE
  2639. if test 3849 -ne `wc -c <'src/sman.n'`; then
  2640.     echo shar: \"'src/sman.n'\" unpacked with wrong size!
  2641. fi
  2642. # end of 'src/sman.n'
  2643. fi
  2644. if test -f 'src/sman_defs.h' -a "${1}" != "-c" ; then 
  2645.   echo shar: Will not clobber existing file \"'src/sman_defs.h'\"
  2646. else
  2647. echo shar: Extracting \"'src/sman_defs.h'\" \(170 characters\)
  2648. sed "s/^X//" >'src/sman_defs.h' <<'END_OF_FILE'
  2649. X
  2650. X#include <limits.h>
  2651. X
  2652. X#define VERSION "1.0"
  2653. X
  2654. X#define Prototype   extern
  2655. X
  2656. X#define MAXPATH     (200)
  2657. X#define NOT_FOUND   LONG_MIN
  2658. X#define ADOC        '+'
  2659. X#define DREF        '@'
  2660. END_OF_FILE
  2661. if test 170 -ne `wc -c <'src/sman_defs.h'`; then
  2662.     echo shar: \"'src/sman_defs.h'\" unpacked with wrong size!
  2663. fi
  2664. # end of 'src/sman_defs.h'
  2665. fi
  2666. echo shar: End of archive 1 \(of 2\).
  2667. cp /dev/null ark1isdone
  2668. MISSING=""
  2669. for I in 1 2 ; do
  2670.     if test ! -f ark${I}isdone ; then
  2671.     MISSING="${MISSING} ${I}"
  2672.     fi
  2673. done
  2674. if test "${MISSING}" = "" ; then
  2675.     echo You have unpacked both archives.
  2676.     rm -f ark[1-9]isdone
  2677. else
  2678.     echo You still need to unpack the following archives:
  2679.     echo "        " ${MISSING}
  2680. fi
  2681. ##  End of shell archive.
  2682. exit 0
  2683. -- 
  2684. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  2685. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  2686. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  2687.